Back to project page libCalendar.
The source code is released under:
MIT License
If you think the Android project libCalendar listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.darkrockstudios.libs.calendar; //w w w.j a v a 2 s .c om import java.util.ArrayList; import android.content.ContentResolver; import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.provider.CalendarContract.Calendars; public class CalendarUtility { private static final String GOOGLE_TYPE = "com.google"; private static final String[] EVENT_PROJECTION = new String[] { Calendars._ID, Calendars.NAME, Calendars.ACCOUNT_NAME, Calendars.ACCOUNT_TYPE, Calendars.CALENDAR_DISPLAY_NAME }; public static Calendar[] getGoogleCalendars( Context context, String account ) { Cursor cur = null; ContentResolver cr = context.getContentResolver(); Uri uri = Calendars.CONTENT_URI; String selection = "((" + Calendars.ACCOUNT_NAME + " = ?) AND (" + Calendars.ACCOUNT_TYPE + " = ?))"; String[] selectionArgs = new String[] { account, GOOGLE_TYPE }; // Submit the query and get a Cursor object back. cur = cr.query( uri, EVENT_PROJECTION, selection, selectionArgs, null ); ArrayList< Calendar > calendarList = new ArrayList< Calendar >(); // Use the cursor to step through the returned records while( cur.moveToNext() ) { Calendar cal = new Calendar( cur ); calendarList.add( cal ); } cur.close(); Calendar[] calendarArray = new Calendar[calendarList.size()]; return calendarList.toArray( calendarArray ); } }