How to Delete all the event from My calendar in my device Android
I found a lot of question or tutorial about that but no one could work for me.
So i will appreciate if someone can give me a complete solution 开发者_开发问答on How to Delete all my event from my calendar
Thanks for Helping!!!!
There is no calendar in the Android OS.
If you are referring to your Google Calendar, use the Google Calendar GData APIs.
try this it ll help u
if ur device is less than 2.1 mean u use below uri
uri="content://calendar/events"
greeater than 2.1 mean
uri="content://com.android.calendar/events"
Cursor cursor=getContentResolver().query(Uri.parse(uri), null, null, null, null);
cursor.moveToFirst();
// fetching calendars id
if(cursor.getcount>0)
{
CId = new int[cursor.getCount()];
int i=0;
while(!cursor.isAfterLast())
{
CId[i] = cursor.getInt(cursor.getColumnIndex("_id"));
i++;
cursor.moveToNext();
}
delete a calender event
for (int i = 0; i < CNames.length; i++)
{
Uri CALENDAR_URI = Uri.parse(uri);
Uri uri = ContentUris.withAppendedId(CALENDAR_URI,Cid[i]);
getContentResolver().delete(uri, null, null);
}
A shorter way:
Uri eventUri = Uri.parse("content://calendar/events"); // or "content://com.android.calendar/events"
Cursor cursor = contentResolver.query(eventUri, new String[]{"_id"}, "calendar_id = " + calendarId, null, null); // calendar_id can change in new versions
while(cursor.moveToNext()) {
Uri deleteUri = ContentUris.withAppendedId(eventUri, cursor.getInt(0));
contentResolver.delete(deleteUri, null, null);
}
精彩评论