CalendarContract.javaAPI DocAndroid 5.1 API108387Thu Mar 12 22:22:10 GMT 2015android.provider


public final class CalendarContract extends Object

The contract between the calendar provider and applications. Contains definitions for the supported URIs and data columns.


CalendarContract defines the data model of calendar and event related information. This data is stored in a number of tables:

  • The {@link Calendars} table holds the calendar specific information. Each row in this table contains the details for a single calendar, such as the name, color, sync info, etc.
  • The {@link Events} table holds the event specific information. Each row in this table has the info for a single event. It contains information such as event title, location, start time, end time, etc. The event can occur one-time or can recur multiple times. Attendees, reminders, and extended properties are stored on separate tables and reference the {@link Events#_ID} to link them with the event.
  • The {@link Instances} table holds the start and end time for occurrences of an event. Each row in this table represents a single occurrence. For one-time events there will be a 1:1 mapping of instances to events. For recurring events, multiple rows will automatically be generated which correspond to multiple occurrences of that event.
  • The {@link Attendees} table holds the event attendee or guest information. Each row represents a single guest of an event. It specifies the type of guest they are and their attendance response for the event.
  • The {@link Reminders} table holds the alert/notification data. Each row represents a single alert for an event. An event can have multiple reminders. The number of reminders per event is specified in {@link Calendars#MAX_REMINDERS} which is set by the Sync Adapter that owns the given calendar. Reminders are specified in minutes before the event and have a type.
  • The {@link ExtendedProperties} table holds opaque data fields used by the sync adapter. The provider takes no action with items in this table except to delete them when their related events are deleted.

Other tables include:

  • {@link SyncState}, which contains free-form data maintained by the sync adapters

Fields Summary
private static final String
public static final String
Broadcast Action: This is the intent that gets fired when an alarm notification needs to be posted for a reminder.
public static final String
Activity Action: Display the event to the user in the custom app as specified in {@link EventsColumns#CUSTOM_APP_PACKAGE}. The custom app will be started via {@link Activity#startActivityForResult(Intent, int)} and it should call {@link Activity#setResult(int)} with {@link Activity#RESULT_OK} or {@link Activity#RESULT_CANCELED} to acknowledge whether the action was handled or not. The custom app should have an intent filter like the following:
<action android:name="android.provider.calendar.action.HANDLE_CUSTOM_EVENT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="" />

Input: {@link Intent#getData} has the event URI. The extra {@link #EXTRA_EVENT_BEGIN_TIME} has the start time of the instance. The extra {@link #EXTRA_CUSTOM_APP_URI} will have the {@link EventsColumns#CUSTOM_APP_URI}.

Output: {@link Activity#RESULT_OK} if this was handled; otherwise {@link Activity#RESULT_CANCELED}.

public static final String
Intent Extras key: {@link EventsColumns#CUSTOM_APP_URI} for the event in the {@link #ACTION_HANDLE_CUSTOM_EVENT} intent
public static final String
Intent Extras key: The start time of an event or an instance of a recurring event. (milliseconds since epoch)
public static final String
Intent Extras key: The end time of an event or an instance of a recurring event. (milliseconds since epoch)
public static final String
Intent Extras key: When creating an event, set this to true to create an all-day event by default
public static final String
This authority is used for writing to or querying from the calendar provider. Note: This is set at first run and cannot be changed without breaking apps that access the provider.
public static final
The content:// style URL for the top-level calendar authority
public static final String
An optional insert, update or delete URI parameter that allows the caller to specify that it is a sync adapter. The default value is false. If set to true, the modified row is not marked as "dirty" (needs to be synced) and when the provider calls {@link ContentResolver#notifyChange(, android.database.ContentObserver, boolean)} , the third parameter "syncToNetwork" is set to false. Furthermore, if set to true, the caller must also include {@link Calendars#ACCOUNT_NAME} and {@link Calendars#ACCOUNT_TYPE} as query parameters.
public static final String
A special account type for calendars not associated with any account. Normally calendars that do not match an account on the device will be removed. Setting the account_type on a calendar to this will prevent it from being wiped if it does not match an existing account.
Constructors Summary
private CalendarContract()
This utility class cannot be instantiated

Methods Summary