CalendarContract
  public
  
  final
  
  class
  CalendarContract
  
    extends Object
  
  
  
  
  
  
| java.lang.Object | |
| ↳ | android.provider.CalendarContract | 
The contract between the calendar provider and applications. Contains definitions for the supported URIs and data columns.
Overview
CalendarContract defines the data model of calendar and event related information. This data is stored in a number of tables:
- The Calendarstable 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 Eventstable 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 theEvents._IDto link them with the event.
- The Instancestable 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 Attendeestable 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 Reminderstable 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 inCalendars.MAX_REMINDERSwhich is set by the Sync Adapter that owns the given calendar. Reminders are specified in minutes before the event and have a type.
- The ExtendedPropertiestable 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:
- 
 SyncState, which contains free-form data maintained by the sync adapters
Summary
| Nested classes | |
|---|---|
| 
        
        
        
        
        class | CalendarContract.AttendeesFields and helpers for interacting with Attendees. | 
| 
        
        
        
        
        interface | CalendarContract.AttendeesColumnsColumns from the Attendees table that other tables join into themselves. | 
| 
        
        
        
        
        class | CalendarContract.CalendarAlertsFields and helpers for accessing calendar alerts information. | 
| 
        
        
        
        
        interface | CalendarContract.CalendarAlertsColumns
 | 
| 
        
        
        
        
        class | CalendarContract.CalendarCacheCalendarCache stores some settings for calendar including the current time zone for the instances. | 
| 
        
        
        
        
        interface | CalendarContract.CalendarCacheColumns
 | 
| 
        
        
        
        
        interface | CalendarContract.CalendarColumnsColumns specific to the Calendars Uri that other Uris can query. | 
| 
        
        
        
        
        class | CalendarContract.CalendarEntityClass that represents a Calendar Entity. | 
| 
        
        
        
        
        interface | CalendarContract.CalendarSyncColumnsGeneric columns for use by sync adapters. | 
| 
        
        
        
        
        class | CalendarContract.CalendarsConstants and helpers for the Calendars table, which contains details for individual calendars. | 
| 
        
        
        
        
        class | CalendarContract.ColorsFields for accessing colors available for a given account. | 
| 
        
        
        
        
        interface | CalendarContract.ColorsColumns
 | 
| 
        
        
        
        
        class | CalendarContract.EventDaysFields and helpers for querying for a list of days that contain events. | 
| 
        
        
        
        
        interface | CalendarContract.EventDaysColumns
 | 
| 
        
        
        
        
        class | CalendarContract.EventsConstants and helpers for the Events table, which contains details for individual events. | 
| 
        
        
        
        
        interface | CalendarContract.EventsColumnsColumns from the Events table that other tables join into themselves. | 
| 
        
        
        
        
        class | CalendarContract.EventsEntityClass that represents an Event Entity. | 
| 
        
        
        
        
        class | CalendarContract.ExtendedPropertiesFields for accessing the Extended Properties. | 
| 
        
        
        
        
        interface | CalendarContract.ExtendedPropertiesColumns
 | 
| 
        
        
        
        
        class | CalendarContract.InstancesFields and helpers for interacting with Instances. | 
| 
        
        
        
        
        class | CalendarContract.RemindersFields and helpers for accessing reminders for an event. | 
| 
        
        
        
        
        interface | CalendarContract.RemindersColumns
 | 
| 
        
        
        
        
        interface | CalendarContract.SyncColumnsColumns for Sync information used by Calendars and Events tables. | 
| 
        
        
        
        
        class | CalendarContract.SyncStateA table provided for sync adapters to use for storing private sync state data. | 
| Constants | |
|---|---|
| String | ACCOUNT_TYPE_LOCALA special account type for calendars not associated with any account. | 
| String | ACTION_EVENT_REMINDERBroadcast Action: This is the intent that gets fired when an alarm notification needs to be posted for a reminder. | 
| String | ACTION_HANDLE_CUSTOM_EVENTActivity Action: Display the event to the user in the custom app as
 specified in  | 
| String | ACTION_VIEW_MANAGED_PROFILE_CALENDAR_EVENTAction used to help apps show calendar events in the managed profile. | 
| String | AUTHORITYThis authority is used for writing to or querying from the calendar provider. | 
| String | CALLER_IS_SYNCADAPTERAn optional insert, update or delete URI parameter that allows the caller to specify that it is a sync adapter. | 
| String | EXTRA_CUSTOM_APP_URIIntent Extras key:  | 
| String | EXTRA_EVENT_ALL_DAYIntent Extras key: When creating an event, set this to true to create an all-day event by default | 
| String | EXTRA_EVENT_BEGIN_TIMEIntent Extras key: The start time of an event or an instance of a recurring event. | 
| String | EXTRA_EVENT_END_TIMEIntent Extras key: The end time of an event or an instance of a recurring event. | 
| String | EXTRA_EVENT_IDIntent Extras key: An extra of type  | 
| Fields | |
|---|---|
| 
    public
    static
    final
    Uri | CONTENT_URIThe content:// style URL for the top-level calendar authority | 
| Public methods | |
|---|---|
| 
        
        
        static
        
        
        boolean | 
      startViewCalendarEventInManagedProfile(Context context, long eventId, long startMs, long endMs, boolean allDay, int flags)
      Starts an activity to view calendar events in the managed profile. | 
| Inherited methods | |
|---|---|
Constants
ACCOUNT_TYPE_LOCAL
public static final String ACCOUNT_TYPE_LOCAL
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.
Constant Value: "LOCAL"
ACTION_EVENT_REMINDER
public static final String ACTION_EVENT_REMINDER
Broadcast Action: This is the intent that gets fired when an alarm notification needs to be posted for a reminder.
Constant Value: "android.intent.action.EVENT_REMINDER"
ACTION_HANDLE_CUSTOM_EVENT
public static final String ACTION_HANDLE_CUSTOM_EVENT
Activity Action: Display the event to the user in the custom app as
 specified in EventsColumns.CUSTOM_APP_PACKAGE. The custom app
 will be started via Activity.startActivityForResult(Intent, int)
 and it should call Activity.setResult(int) with
 Activity.RESULT_OK or Activity.RESULT_CANCELED to
 acknowledge whether the action was handled or not.
 The custom app should have an intent filter like the following:
 
 <intent-filter>
    <action android:name="android.provider.calendar.action.HANDLE_CUSTOM_EVENT" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="vnd.android.cursor.item/event" />
 </intent-filter>
 Input: Intent.getData has the event URI. The extra
 EXTRA_EVENT_BEGIN_TIME has the start time of the instance. The
 extra EXTRA_CUSTOM_APP_URI will have the
 EventsColumns.CUSTOM_APP_URI.
 
 Output: Activity.RESULT_OK if this was handled; otherwise
 Activity.RESULT_CANCELED.
Constant Value: "android.provider.calendar.action.HANDLE_CUSTOM_EVENT"
ACTION_VIEW_MANAGED_PROFILE_CALENDAR_EVENT
public static final String ACTION_VIEW_MANAGED_PROFILE_CALENDAR_EVENT
Action used to help apps show calendar events in the managed profile.
Constant Value: "android.provider.calendar.action.VIEW_MANAGED_PROFILE_CALENDAR_EVENT"
AUTHORITY
public static final String AUTHORITY
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.
Constant Value: "com.android.calendar"
CALLER_IS_SYNCADAPTER
public static final String CALLER_IS_SYNCADAPTER
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
 ContentResolver.notifyChange(android.net.Uri, android.database.ContentObserver, boolean)
 , the third parameter "syncToNetwork" is set to false. Furthermore, if
 set to true, the caller must also include
 Calendars.ACCOUNT_NAME and Calendars.ACCOUNT_TYPE as
 query parameters.
Constant Value: "caller_is_syncadapter"
EXTRA_CUSTOM_APP_URI
public static final String EXTRA_CUSTOM_APP_URI
Intent Extras key: EventsColumns.CUSTOM_APP_URI for the event in
 the ACTION_HANDLE_CUSTOM_EVENT intent
Constant Value: "customAppUri"
EXTRA_EVENT_ALL_DAY
public static final String EXTRA_EVENT_ALL_DAY
Intent Extras key: When creating an event, set this to true to create an all-day event by default
Constant Value: "allDay"
EXTRA_EVENT_BEGIN_TIME
public static final String EXTRA_EVENT_BEGIN_TIME
Intent Extras key: The start time of an event or an instance of a recurring event. (milliseconds since epoch)
Constant Value: "beginTime"
EXTRA_EVENT_END_TIME
public static final String EXTRA_EVENT_END_TIME
Intent Extras key: The end time of an event or an instance of a recurring event. (milliseconds since epoch)
Constant Value: "endTime"
EXTRA_EVENT_ID
public static final String EXTRA_EVENT_ID
Intent Extras key: An extra of type long holding the id of an event.
Constant Value: "id"
Fields
CONTENT_URI
public static final Uri CONTENT_URI
The content:// style URL for the top-level calendar authority
Public methods
startViewCalendarEventInManagedProfile
public static boolean startViewCalendarEventInManagedProfile (Context context, long eventId, long startMs, long endMs, boolean allDay, int flags)
Starts an activity to view calendar events in the managed profile.
 When this API is called, the system will attempt to start an activity
 in the managed profile with an intent targeting the same caller package.
 The intent will have its action set to
 CalendarContract.ACTION_VIEW_MANAGED_PROFILE_CALENDAR_EVENT and contain extras
 corresponding to the API's arguments. A calendar app intending to support
 cross-profile events viewing should handle this intent, parse the arguments
 and show the appropriate UI.
| Parameters | |
|---|---|
| context | Context: the context.
 This value cannot benull. | 
| eventId | long: the id of the event to be viewed. Will be put intoEXTRA_EVENT_IDfield of the intent. | 
| startMs | long: the start time of the event in milliseconds since epoch.
                Will be put intoEXTRA_EVENT_BEGIN_TIMEfield of the intent. | 
| endMs | long: the end time of the event in milliseconds since epoch.
              Will be put intoEXTRA_EVENT_END_TIMEfield of the intent. | 
| allDay | boolean: if the event is an all-day event. Will be put intoEXTRA_EVENT_ALL_DAYfield of the intent. | 
| flags | int: flags to be set on the intent viaIntent.setFlags | 
| Returns | |
|---|---|
| boolean | trueif the activity is started successfully.falseotherwise. | 
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
