Question

I have a sync adapter that handles syncing calendars and events. I am able to delete normal events just fine. But whenever I delete a recurring event, all the events on my calendar disappear.

One thing I noticed is that whenever I deleted a recurring event, the Instances table is emptied, which explains the events disappearing. The Events table is as expected, with the recurring event row deleted from the table.

What is causing this?

I have tried deleting in the following ways:

resolver.delete(
    ContentUris.withAppendedId(Events.CONTENT_URI, id),
    null,
    null
);

resolver.delete(
    Events.CONTENT_URI,
    Events._ID + " = ?",
    new String[]{id}
);

And also as a SyncAdapter:

resolver.delete(
    Events.CONTENT_URI.buildUpon()
    .appendQueryParameter(CalendarContract.CALLER_IS_SYNCADAPTER, "true")
    .appendQueryParameter(Calendars.ACCOUNT_NAME, account.name)
    .appendQueryParameter(Calendars.ACCOUNT_TYPE, account.type)
    .build(),
    Events._ID + " = ?",
    new String[]{id}
);

All methods work correctly on non-recurring events, but all cause the Instances table to be emptied when deleting a recurring event.

Update

One thing I noticed is that the LogCat spits out the following error

  • Application: system_process
  • Tag: BufferQueue
  • PID: 1187
  • TID: 1518

[com.android.calendar/com.android.calendar.AllInOneActivity] BufferQueue:drainQueueLocked: timeout waiting on consumer!

Was it helpful?

Solution

It turned out to be an error on my part. When my SyncAdapter was adding calendars to the database, I was not properly setting the field SYNC_EVENTS (http://developer.android.com/reference/android/provider/CalendarContract.CalendarColumns.html#SYNC_EVENTS). Specifically, this field should be set to 1.

It was difficult to know that this was the issue because I was still able to technically "sync" (push events to the server and pull events from the server), but I was just running into the issue my events disappearing.

I hope this helps someone else too.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top