Cannot delete Android calendar

Viewed 1120

I've been playing around with the Android Calendar Provider to create local (non-synced) calendars but I finally ended up with calendars with null ACCOUNT_TYPE and ACCOUNT_NAME. I can see them in:

getContentResolver().query(CalendarContract.Calendars.CONTENT_URI, null, CalendarContract.Calendars.ACCOUNT_TYPE + " IS NULL", null, null);

And now my Google Calendar app crashes at startup :(

I've tried to delete these dummy calendars with this piece of code (after succesfully requesting the WRITE_CALENDAR permission):

getContentResolver().delete(CalendarContract.Calendars.CONTENT_URI, CalendarContract.Calendars.ACCOUNT_TYPE + " IS NULL", null);

but it raises the following error

java.lang.IllegalArgumentException: the name must not be empty: null at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:165) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135) at android.content.ContentProviderProxy.delete(ContentProviderNative.java:544) at android.content.ContentResolver.delete(ContentResolver.java:1327)

which, I assume, is caused by their account type/name being null.

Do you have any idea of how I could get rid of them?

NB: Device's Android version is 6.0.1

2 Answers
Related