I created an application that easily puts the values that I want in the device’s calendar, but when I want to programmatically remove it from the calendar, I can’t find a way to do this.
I searched the web, basically other stackoverflow related questions, to find the answer (links here):
Delete calendar entry ,
Calendar events not deleted .
Delete a specific event .
I found a way to delete all event entries in the calendar:
public void onClick(View v) { Uri eventsUri = Uri.parse("content://com.android.calendar/events"); ContentResolver cr = getContentResolver(); Cursor cursor; cursor = cr.query(eventsUri, new String[]{ "_id" },"calendar_id=" + 1, null, null); while(cursor.moveToNext()) { long eventId = cursor.getLong(cursor.getColumnIndex("_id")); cr.delete(ContentUris.withAppendedId(eventsUri, eventId), null, null); } cursor.close();
It works, but I want to delete only one specific entry. So my questions are:
1.) Can you give me a link or a snippet of code on how to delete a specific event in the Android calendar?
2.) Is it possible to delete a calendar entry simply by finding its title
?
source share