Jak usunąć pozycję kalendarza?
Próbuję wdrożyć mój pierwszy program na Androida. Powinien pisać wpisy kalendarza (wiem, nie najlepsze zadanie, aby rozpocząć programowanie Andorida).
Próbowałem:
Uri CALENDAR_URI = Uri.parse("content://calendar/events");
ContentResolver cr = getContentResolver();
cr.delete(CALENDAR_URI, null, null); // Delete all
cr.delete(CALENDAR_URI, "calendar_id=1", null); // Delete all in default calendar
cr.delete(CALENDAR_URI, "_id=1", null); // Delete specific entry
Nic nie działało. Nakładam „nie mogę usunąć tego adresu URL”.
Wstawianie wpisu kalendarza było proste:
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);
Zgodnie z moją metodą wstawiania dostęp do kalendarza działał.
Dzięki, Arthurze!