How can I delete event from calendar on android >= 8?
The answer was in front of me from the start...
I was calling CalendarContract.Calendar
and not CalendarContract.Event
.
I was able to test this on different devices and everything works.
public void deleteEventCalendar(Context myContext) {
Uri deleteUri = null;
Cursor cursor = myContext.getContentResolver().query(CalendarContract.Events.CONTENT_URI, null, null, null, null);
while (cursor.moveToNext()) {
long id = cursor.getLong(cursor.getColumnIndexOrThrow(CalendarContract.Events._ID));
deleteUri = ContentUris.withAppendedId(CalendarContract.Events.CONTENT_URI, id);
Log.i("id calendar","mon id"+id);
myContext.getContentResolver().delete(deleteUri, null, null);
}
cursor.close();
}