Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete only one instance of a recurring event from my Android calendar

I've been looking through the various posts on how to delete just one instance of a recurring event from my Android 2.3 Phone's calendar, but I haven't been able to find the perfect answer. So far, the best I've come across is :

Uri eventsUri = Uri.parse("content://com.android.calendar/events");
Uri deleteEventUri = Uri.withAppendedPath(eventsUri, String.valueOf(id2));
DeleteEventActivity.context.getContentResolver().delete(deleteEventUri, null, null);

Where id2 is the id of the event I want to delete. The problem I have is that I only want to delete one instance of a recurring event, but this code deletes all occurrences. Is there a way to delete only one instance? Thanks.

like image 209
Stuart McLaren Avatar asked May 05 '12 13:05

Stuart McLaren


People also ask

How do you stop a single occurrence of a recurring meeting in Google Calendar?

If you want to delete the event (either singularly, or for all or past recurring events), select the event title in your calendar, then select the Delete button. You'll be given options to delete a single event, or all or past recurring events. Select one of the available options, then select “OK” to confirm.

How do I delete an automatic event in Google Calendar?

Click on the gear icon and then select 'Settings' from the available options. When in the Google Calendar settings menu, look through the left panel and select 'Events from Gmail'. It will be grouped under General tab. Now, untick the checkbox beside 'Show events automatically created by Gmail in my calendar'.


1 Answers

Here are the basics

  1. Find the instance you want to delete. (using Instances.query())
  2. Create the exception URI with the event ID appended.
  3. Create ContentValues. Put your instance's BEGIN value as ...Events.ORIGINAL_INSTANCE_TIME. Put STATUS_CANCELED as ...Events.STATUS
  4. Now only insert(yourURI, yourValues) and that's it!
like image 120
Alex.F Avatar answered Oct 09 '22 17:10

Alex.F