Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>That code above is pretty awful (and it does not seem to work in ICS - definitely the column names are different)</p> <p>The page here: <a href="http://developer.android.com/guide/topics/providers/calendar-provider.html" rel="noreferrer">http://developer.android.com/guide/topics/providers/calendar-provider.html</a></p> <p>provides a much better overview. A (much) simpler code to retrieve calendars:</p> <pre><code>public class CalendarContentResolver { public static final String[] FIELDS = { CalendarContract.Calendars.NAME, CalendarContract.Calendars.CALENDAR_DISPLAY_NAME, CalendarContract.Calendars.CALENDAR_COLOR, CalendarContract.Calendars.VISIBLE }; public static final Uri CALENDAR_URI = Uri.parse("content://com.android.calendar/calendars"); ContentResolver contentResolver; Set&lt;String&gt; calendars = new HashSet&lt;String&gt;(); public CalendarContentResolver(Context ctx) { contentResolver = ctx.getContentResolver(); } public Set&lt;String&gt; getCalendars() { // Fetch a list of all calendars sync'd with the device and their display names Cursor cursor = contentResolver.query(CALENDAR_URI, FIELDS, null, null, null); try { if (cursor.getCount() &gt; 0) { while (cursor.moveToNext()) { String name = cursor.getString(0); String displayName = cursor.getString(1); // This is actually a better pattern: String color = cursor.getString(cursor.getColumnIndex(CalendarContract.Calendars.CALENDAR_COLOR)); Boolean selected = !cursor.getString(3).equals("0"); calendars.add(displayName); } } } catch (AssertionError ex) { /*TODO: log exception and bail*/ } return calendars; } } </code></pre> <p>Hope this helps!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload