Как удалить конкретное событие в календаре

Я хочу удалить только содержимое, которое я сохраняю в календаре, вместо всего содержимого, которое я уже присутствует в календаре ... для этого я использую следующий код ... но он удалит все содержимое календаря ... так что кто-нибудь может сказать мне, как это можно предотвратить ...

Uri CALENDAR_URI = Uri.parse("content://calendar/events");
ContentResolver cr = getContentResolver();
cr.delete(CALENDAR_URI, null, null); // Delete all



ContentValues values = new ContentValues();
values.put("calendar_id", 1);
values.put("title", this.title);
values.put("allDay", this.allDay);
values.put("dtstart", this.dtstart.toMillis(false));
values.put("dtend", this.dtend.toMillis(false));
values.put("description", this.description);
values.put("eventLocation", this.eventLocation);
values.put("visibility", this.visibility);
values.put("hasAlarm", this.hasAlarm);

cr.insert(CALENDAR_URI, values);

поэтому я хочу удалить только это введенные мной записи ...

удаление события

Uri EVENTS_URI = Uri.parse("content://com.android.calendar/" + "events");

ContentResolver cr = c.getContentResolver();
deleteEvent(cr, EVENTS_URI, 1);

private void deleteEvent(ContentResolver resolver, Uri eventsUri, int calendarId) {
        Cursor cursor;     
        cursor = resolver.query(eventsUri, new String[]{ "_id" },     "calendar_id=" + calendarId, null, null);
        while(cursor.moveToNext()) {
            long eventId = cursor.getLong(cursor.getColumnIndex("_id"));
            resolver.delete(ContentUris.withAppendedId(eventsUri, eventId), null, null);
        }
        cursor.close();
    }
5
задан Kowser 3 August 2011 в 12:05
поделиться