我有以编程方式插入日历条目的代码。在日历API中插入时,一切正常。 问题是当应用程序未被应用时,应用程序创建的日历事件不会被删除。我错过了什么?任何帮助都会提前感谢!!
答案 0 :(得分:0)
试试这个..
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);
}