Is there a way to access the calendar's entries without using gdata-java-client?

后端 未结 7 611
星月不相逢
星月不相逢 2020-12-08 18:05

Is it possible to get the calendar\'s entries from the phone offline? It seem the only way is to use gdata-java-client.

相关标签:
7条回答
  • 2020-12-08 18:47

    You can use the calendar content provider (com.android.providers.calendar.CalendarProvider). Example:

    
    ContentResolver contentResolver = context.getContentResolver();
    Cursor cursor = contentResolver.query(Uri.parse("content://calendar/events"), null, null, null, null);
    
    while(cursor.moveToNext()) {
        String eventTitle = cursor.getString(cursor.getColumnIndex("title"));
        Date eventStart = new Date(cursor.getLong(cursor.getColumnIndex("dtstart")));
        // etc.
    }
    
    

    edit: you might want to put this in a wrapper (see Isaac's post) as it's currently a private API.

    0 讨论(0)
提交回复
热议问题