The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.


The CalendarContract Provider

The Android Open Source Project (AOSP) has had a Calendar application from its earliest days. This application originally was designed to sync with Google Calendar, later extended to other sync sources, such as Microsoft’s Exchange. However, this application was not part of the Android SDK, so there was no way to access it from your Android application.

At least, no officially documented and supported way.

Many developers poked through the AOSP source code and found that the Calendar application had a ContentProvider. Moreover, this ContentProvider was exported (by default). So many developers used undocumented and unsupported means for accessing calendar information. This occasionally broke, as Google modified the Calendar app and changed these pseudo-external interfaces.

Android 4.0 added official SDK support for interacting with the Calendar application via its ContentProvider. As part of the SDK, these new interfaces should be fairly stable — if nothing else, they should be supported indefinitely, even if new and improved interfaces are added sometime in the future. So, if you want to tie into the user’s calendars, you can. Bear in mind, though, that the new CalendarContract ContentProvider is not identical to the older undocumented providers, so if you are aiming to support pre-4.0 devices, you have some more work to do.

Of course, similar to the ContactsContract ContentProvider, the CalendarContract ContentProvider is severely lacking in documentation, and anything not documented is subject to change.

Prerequisites

Understanding this chapter requires that you have read the chapters on:

You Can’t Be a Faker

The preview of this section is being chased by zombies.

Do You Have Room on Your Calendar?

The preview of this section is sleeping in.

Calendar Permissions

The preview of this section was traded for a bag of magic beans.

Querying for Events

The preview of this section was fed to a gremlin, after midnight.

Penciling In an Event

The preview of this section did not survive Thanos's finger snap.