The calendar content provider is not officially published in the Android SDK but after searching through the Android source code I have finally figured out how to add events to calendars. This tutorial only covers adding events to calendars. It does not cover reading events from calendars. Before you can add an event to a calendar, you need to know which calendars exists and what their identifiers are. Cursor cursor = cr.query(Uri.parse("content://calendar/calendars"), new String[]{ "_id", "displayname" }, null, null, null);To actually add an event to a calendar, start by creating a ContentValues object. Put a calendar_id from the array above in there along with the title, date and location for the event. It should look something like this: ContentValues cv = new ContentValues();cr.insert(Uri.parse("content://calendar/events"), cv);As this content provider is not officially public, it could change in future Android versions which might break your app. |