Check if the calendar is primary

I am fetching all the calendars with:

    Cursor cursor = getContentResolver().query(Uri.parse("content://"),
            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



returns -1


Any ideas what I am doing wrong?


source to share

2 answers

I tried this on some phones and it seems that there is no IS_PRIMARY column on some phones. Therefore, you should not rely on this field. The phone he didn't work with was the HTC Sensation XE. He was present on Nexus phones (Galaxy Nexus and Nexus 5).



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.



All Articles