Android examples for Android OS:Calendar Contract
print Calendars
import android.annotation.TargetApi; import android.content.ContentResolver; import android.content.ContentUris; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.DatabaseUtils; import android.net.Uri; import android.os.Build; import android.provider.CalendarContract; import android.util.Log; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main{ private static final String TAG = CalendarUtil.class.getSimpleName(); public static void printCalendars(Context context) { runGenericQuery(context, "Calendars", CalendarContract.Calendars.CONTENT_URI); }/*ww w . j av a 2 s .c om*/ private static void runGenericQuery(Context context, String queryName, Uri queryUri) { // Run query Cursor cursor; ContentResolver cr = context.getContentResolver(); // Submit the query and get a Cursor object back. cursor = cr.query(queryUri, null, null, null, null); String cursorContent = DatabaseUtils.dumpCursorToString(cursor); if (cursor != null) { cursor.close(); } Log.i(TAG, "------- " + queryName + " cursorContent: \n" + cursorContent); } }