Android examples for Android OS:Calendar Event
print Calendar Events
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 printEvents(Context context) { runGenericQuery(context, "Events", CalendarContract.Events.CONTENT_URI); }/*from www .j av a 2s . com*/ 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); } }