使用此代码,我的队友正在添加日历事件。这没有问题。日历事件显示在谷歌日历中。
TimeZone timeZone = TimeZone.getDefault();
ContentResolver cr = getContentResolver();
ContentValues values = new ContentValues();
values.put(CalendarContract.Events.EVENT_TIMEZONE, timeZone.getID());
values.put(CalendarContract.Events.DTSTART, startInMillis);
values.put(CalendarContract.Events.DTEND, endInMillis);
values.put(CalendarContract.Events.TITLE, title);
values.put(CalendarContract.Events.EVENT_LOCATION, "Raum: " + location);
values.put(CalendarContract.Events.DESCRIPTION,
"Dauer der Veranstaltung: " + duration + " min" + "---|---Dozent: "
+ organizer.trim() + "---|---Course added by UNIDATE---|");
values.put(CalendarContract.Events.CALENDAR_ID, 1);
Uri uri = cr.insert(CalendarContract.Events.CONTENT_URI, values);
ContentUris.withAppendedId(uri, id);
但现在我想通过他们的 id 删除这些事件。我用过这段代码(除其他外):
long selectedEventId = 1;
String[] selArgs = new String[]{Long.toString(selectedEventId)};
int deleted = getContentResolver().delete(CalendarContract.Events.CONTENT_URI, Events._ID + " =? ", selArgs);
这行不通。我也尝试添加
values.put(CalendarContract.Events._ID, id);