android - Calendar query sorted by date and time -


i trying return query of calendar events sorted date , time can iterate through them. have queried so:

private cursor mcursor = null; private static final string[] cols = new string[]{calendarcontract.events.title, calendarcontract.events.dtstart, calendarcontract.events.availability}; mcursor = getcontentresolver().query(calendarcontract.events.content_uri, cols, null, null, null); mcursor.movetolast(); 

this works great except seems return calendar events based on when created , not date , time. example, if create new event december 25, 2012, show last result.

my end goal find first event starts before current time. example, if 8:00am, want find first event starts before 8:00am. want check duration of event see if ongoing event.

is there easy way return query sorted date , time or have implement sort after results queried? better yet, there simple way find first event before current time?

maybe this?

    private cursor mcursor = null;     private static final string[] cols = new string[]{calendarcontract.events.title, calendarcontract.events.dtstart, calendarcontract.events.availability};     mcursor = getcontentresolver().query(calendarcontract.events.content_uri, cols, null, null, calendarcontract.events.dtstart + "asc");     mcursor.movetolast(); 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -