11

Can anybody show me how can i modify(Edit) and delete android calendar events which has been added by the user itself using my android application. I have tried a lot but none of them working fine for me. i am dealing with these calenders first time. Do we have a solution for this?

Rince Thomas
  • 4,158
  • 5
  • 25
  • 44
Droid_Dev
  • 1,162
  • 1
  • 8
  • 25

1 Answers1

0

Take a look at this question: StackOverflow

This code worked for me.

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();
// Show message
Toast.makeText(getApplicationContext(), "Calendar Cleared!",Toast.LENGTH_LONG).show();
Euler Tiago
  • 134
  • 2
  • 4