1
使用此代碼,我的隊友正在添加日曆活動。這工作沒有問題。日曆事件顯示在谷歌日曆中。如何通過他們的ID添加日曆事件並通過他們的ID刪除他們? (Android 4.0)
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);
deleteUri = ContentUris.withAppendedId(Events.CONTENT_URI,事件ID); int rows = getContentResolver()。delete(deleteUri,null,null); – sam
from http://developer.android.com/guide/topics/providers/calendar-provider.html ...可能嗎? – sam
我現在嘗試並向您報告 – Mladen