delete events from Calendar Provider on Android

徘徊边缘 提交于 2019-12-04 17:17:30

As you noticed, deleting an event doesn't really remove the row from the DB until the event is synced to the server. It's quite logical, otherwise the calendar sync adapter would not be able to retrieve event data to send a DELETE request to the server. That's why there is a DELETED column in the event table, which you must check when querying events:

http://developer.android.com/reference/android/provider/CalendarContract.SyncColumns.html#DELETED

By the way if you query Instances instead of Events (which does expansion of recurring events), deleted events are removed automatically from the result.

SOLVED. Basically the problem is that the event seemed to be locally removed on the phone, but was not yet synced with my Google Account. After syncing, the events were both removed from my phone and my Google Account associated to the phone.

This is another proof how annoying can be programming on Android, specially when special attention is not given to little details like these. I lost 2 days just to find out this basic issue...

There are two versions of delete: as an application and as a sync adapter. An application delete sets the deleted column to 1. This flag that tells the sync adapter that the row was deleted and that this deletion should be propagated to the server. A sync adapter delete removes the event from the database along with all its associated data.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!