Check if the calendar is primary
I am fetching all the calendars with:
Cursor cursor = getContentResolver().query(Uri.parse("content://com.android.calendar/calendars"),
null, null, null, null);
The cursor contains all the calendars that I am using. According to the documentation , the cursor should contain a column indicating whether the calendar is the user's primary calendar. Nevertheless
cursor.getColumnIndex("isPrimary");
returns -1
.
Any ideas what I am doing wrong?
+3
source to share
2 answers
I just tried the same on a Google Nexus 7 tablet with Android 5.1.1. The result was a pointer in the cursor without an alias for isPrimary. His name instead
COALESCE (isPrimary, ownerAccount = account_name)
Now I am checking if the column index is -1 for isPrimary and so I am using the above name for the column.
I still don't know why this is happening, but it seems to be a missing alias in implementation on some devices.
+1
source to share