Many thanks! However, you received all events from only one Calendar, for example, your main Google account, how can you receive events from ALL available calendars?
Please note that on your built-in calendar widget you can see events from Gmail, Exchange, Facebook, etc. How to get these events?
Regarding specific events for a date or a week, I did this using a selection offer and Args selection in the request, for example, for a specific day:
Here are the choices and definitions of args:
Uri content = Uri.parse("content://com.android.calendar/events"); String[] vec = new String[] { "calendar_id", "title", "description", "dtstart", "dtend", "allDay", "eventLocation" }; String selectionClause = "(dtstart >= ? AND dtend <= ?) OR (dtstart >= ? AND allDay = ?)"; String[] selectionsArgs = new String[]{"" + dtstart, "" + dtend, "" + dtstart, "1"};
And here is what the request looks like:
ContentResolver contentResolver = context.getContentResolver(); Cursor cursor = contentResolver.query(content, vec, selectionClause, selectionsArgs, null);
Moti Bartov
source share