Android examples for Android OS:Calendar Event
start Calendar Event Query
import android.content.AsyncQueryHandler; import android.net.Uri; public class Main{ private static final Uri CALENDAR_CONTENT_URI = Uri .parse("content://calendar/calendars"); private static final Uri CALENDAR_CONTENT_URI_FROYO_PLUS = Uri .parse("content://com.android.calendar/calendars"); private static final String[] CALENDARS_PROJECTION = new String[] { "_id", // BaseColumns._ID, "displayName" //Calendars.DISPLAY_NAME };/*ww w . java 2 s. c o m*/ private static final String[] CALENDARS_PROJECTION_ICS_PLUS = new String[] { "_id", // BaseColumns._ID, "calendar_displayName" //CalendarColumns.CALENDAR_DISPLAY_NAME }; private static final String CALENDARS_WHERE = "access_level>=500 AND sync_events=1"; private static final String CALENDARS_WHERE_ICS_PLUS = "calendar_access_level>=500 AND sync_events=1"; public static void startQuery(AsyncQueryHandler queryHandler) { queryHandler.startQuery(0, null, getCalendarContentUri(), CalendarUtils.getCalendarProjection(), CalendarUtils.getCalendarWhereClause(), null /* selection args */, null /* use default sort */); } private static Uri getCalendarContentUri() { Uri uri; if (OSUtils.atLeastFroyo()) { uri = CALENDAR_CONTENT_URI_FROYO_PLUS; } else { uri = CALENDAR_CONTENT_URI; } return uri; } private static String[] getCalendarProjection() { String[] projection; if (OSUtils.atLeastICS()) { projection = CALENDARS_PROJECTION_ICS_PLUS; } else { projection = CALENDARS_PROJECTION; } return projection; } private static String getCalendarWhereClause() { String where; if (OSUtils.atLeastICS()) { where = CALENDARS_WHERE_ICS_PLUS; } else { where = CALENDARS_WHERE; } return where; } }