If anyone else is struggling with this, I finally hacked it!
It turns out that you are not deleting or modifying any entries that you are actually doing is to insert a new event called an exception. It took me several months to find this information anywhere, and even finding it, a few more months to work out what needed to be included in the exception in order to make it work, thatβs how I did it.
First, request the actual instance of the event that you want to cancel in one case. You need to query the CalendarContract.Instances table to get the values ββof CalendarContract.Instances.TITLE, CalendarContract.Instances.BEGIN and CalendarContract.Instances.EVENT_ID. The way I do this in my code does not really fit into the context of this answer, so I hope you can decide how to do it yourself. Save these values ββas:
final String title = eventCursor.getString(0); final long beginl=eventCursor.getLong(1); final int id = eventCursor.getInt(2);
Then we need to configure the new event as follows:
final Context context = getApplicationContext(); final ContentResolver contentResolver = context.getContentResolver(); final Uri.Builder builder = Uri.parse( "content://com.android.calendar/events").buildUpon(); final Cursor eventCursor = contentResolver.query(builder.build(), new String[] {Events.CALENDAR_TIME_ZONE,Events.ALL_DAY,Events.CALENDAR_ID,Events._SYNC_ID, Events.OWNER_ACCOUNT }, "_id=" + id, null, null); while (eventCursor.moveToNext()) { final String timezone=eventCursor.getString(0); final String allday=eventCursor.getString(1); final long calID=eventCursor.getLong(2); final String mSyncId=eventCursor.getString(3); final String account=eventCursor.getString(4); ContentValues values = new ContentValues(); values.put(Events.TITLE, title); values.put(Events.EVENT_TIMEZONE, timezone); values.put(Events.ORIGINAL_SYNC_ID, mSyncId);
Hope this works, I tried to cut out parts of my code that are not relevant. You will notice that I need to add 3,600,000 to the beginl value (1 hour in milliseconds). I guess this is because we are in BST at the moment, and this code will not work as soon as the clock changes, but I will worry about it at that time!
Finally, I used an application called Content Provider Helper to help me find this. You can use it to query content provider tables. I would try to set up an exception using my code, and then use the Calendar application to delete the instance and compare the two entries.