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?
Update and delete calendar events in android through my application
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();
© 2022 - 2024 — McMap. All rights reserved.