I've created an android app that adds events to any of my google calendars. It works so far but the events that I create are only visible in my local calendar app and not on the web. Here is the code I use to insert the events:
ContentResolver contentResolver = getContentResolver();
for (Date date : getDates()) {
ContentValues values = new ContentValues();
values.put(Events.CALENDAR_ID, calendar.getId());
values.put(Events.TITLE, type.getName());
values.put(Events.DTSTART, buildStartDate(date));
values.put(Events.DTEND, buildEndDate(date));
values.put(Events.ALL_DAY, 0);
values.put(Events.EVENT_TIMEZONE, TimeZone.getDefault().getID());
Uri event = contentResolver.insert(
CalendarContract.Events.CONTENT_URI, values);
Toast.makeText(getApplicationContext(),
"Inserted event: " + event.toString(),
Toast.LENGTH_LONG).show();
}
The caledar.getId()
returns the Id of the calendar I've selected previously. buildStartDate
and buildEndDate
creates the start and the end date and returns it as milli seconds. The type.getName()
returns just a string that is used as the title.
Does anyone know why the events are only displayed in my local calendar app? When I use the calendar app to insert a new event, it is synced to the web, so the syncing does work.