Update and delete calendar events in android through my application
Asked Answered
R

1

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?

Remontant answered 5/3, 2013 at 11:52 Comment(0)
M
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();
Mindful answered 28/11, 2018 at 17:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.