Added in API level 14

CalendarContract


class CalendarContract
kotlin.Any
   ↳ 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 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 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 Events#_ID to link them with the event.
  • The 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 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 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 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 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:

  • SyncState, which contains free-form data maintained by the sync adapters

Summary

Nested classes

Fields and helpers for interacting with Attendees.

abstract

Columns from the Attendees table that other tables join into themselves.

Fields and helpers for accessing calendar alerts information.

abstract

CalendarCache stores some settings for calendar including the current time zone for the instances.

abstract

abstract

Columns specific to the Calendars Uri that other Uris can query.

Class that represents a Calendar Entity.

abstract

Generic columns for use by sync adapters.

Constants and helpers for the Calendars table, which contains details for individual calendars.

Fields for accessing colors available for a given account.

abstract

Fields and helpers for querying for a list of days that contain events.

abstract

Constants and helpers for the Events table, which contains details for individual events.

abstract

Columns from the Events table that other tables join into themselves.

Class that represents an Event Entity.

Fields for accessing the Extended Properties.

abstract

Fields and helpers for interacting with Instances.

Fields and helpers for accessing reminders for an event.

abstract

abstract

Columns for Sync information used by Calendars and Events tables.

A table provided for sync adapters to use for storing private sync state data.

Constants
static String

A special account type for calendars not associated with any account.

static String

Broadcast Action: This is the intent that gets fired when an alarm notification needs to be posted for a reminder.

static String

Activity Action: Display the event to the user in the custom app as specified in EventsColumns#CUSTOM_APP_PACKAGE.

static String

Action used to help apps show calendar events in the managed profile.

static String

This authority is used for writing to or querying from the calendar provider.

static String

An optional insert, update or delete URI parameter that allows the caller to specify that it is a sync adapter.

static String

Intent Extras key: EventsColumns#CUSTOM_APP_URI for the event in the ACTION_HANDLE_CUSTOM_EVENT intent

static String

Intent Extras key: When creating an event, set this to true to create an all-day event by default

static String

Intent Extras key: The start time of an event or an instance of a recurring event.

static String

Intent Extras key: The end time of an event or an instance of a recurring event.

static String

Intent Extras key: An extra of type long holding the id of an event.

Public methods
static Boolean
startViewCalendarEventInManagedProfile(context: Context, eventId: Long, startMs: Long, endMs: Long, allDay: Boolean, flags: Int)

Starts an activity to view calendar events in the managed profile.

Properties
static Uri!

The content:// style URL for the top-level calendar authority

Constants

ACCOUNT_TYPE_LOCAL

Added in API level 14
static val ACCOUNT_TYPE_LOCAL: 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.

Value: "LOCAL"

ACTION_EVENT_REMINDER

Added in API level 14
static val ACTION_EVENT_REMINDER: String

Broadcast Action: This is the intent that gets fired when an alarm notification needs to be posted for a reminder.

Value: "android.intent.action.EVENT_REMINDER"

ACTION_HANDLE_CUSTOM_EVENT

Added in API level 16
static val ACTION_HANDLE_CUSTOM_EVENT: String

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.

Value: "android.provider.calendar.action.HANDLE_CUSTOM_EVENT"

ACTION_VIEW_MANAGED_PROFILE_CALENDAR_EVENT

Added in API level 29
static val ACTION_VIEW_MANAGED_PROFILE_CALENDAR_EVENT: String

Action used to help apps show calendar events in the managed profile.

Value: "android.provider.calendar.action.VIEW_MANAGED_PROFILE_CALENDAR_EVENT"

AUTHORITY

Added in API level 14
static val AUTHORITY: 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.

Value: "com.android.calendar"

CALLER_IS_SYNCADAPTER

Added in API level 14
static val CALLER_IS_SYNCADAPTER: 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 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.

Value: "caller_is_syncadapter"

EXTRA_CUSTOM_APP_URI

Added in API level 16
static val EXTRA_CUSTOM_APP_URI: String

Intent Extras key: EventsColumns#CUSTOM_APP_URI for the event in the ACTION_HANDLE_CUSTOM_EVENT intent

Value: "customAppUri"

EXTRA_EVENT_ALL_DAY

Added in API level 14
static val EXTRA_EVENT_ALL_DAY: String

Intent Extras key: When creating an event, set this to true to create an all-day event by default

Value: "allDay"

EXTRA_EVENT_BEGIN_TIME

Added in API level 14
static val EXTRA_EVENT_BEGIN_TIME: String

Intent Extras key: The start time of an event or an instance of a recurring event. (milliseconds since epoch)

Value: "beginTime"

EXTRA_EVENT_END_TIME

Added in API level 14
static val EXTRA_EVENT_END_TIME: String

Intent Extras key: The end time of an event or an instance of a recurring event. (milliseconds since epoch)

Value: "endTime"

EXTRA_EVENT_ID

Added in API level 29
static val EXTRA_EVENT_ID: String

Intent Extras key: An extra of type long holding the id of an event.

Value: "id"

Public methods

startViewCalendarEventInManagedProfile

Added in API level 29
static fun startViewCalendarEventInManagedProfile(
    context: Context,
    eventId: Long,
    startMs: Long,
    endMs: Long,
    allDay: Boolean,
    flags: Int
): Boolean

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 be null.
eventId Long: the id of the event to be viewed. Will be put into EXTRA_EVENT_ID field of the intent.
startMs Long: the start time of the event in milliseconds since epoch. Will be put into EXTRA_EVENT_BEGIN_TIME field of the intent.
endMs Long: the end time of the event in milliseconds since epoch. Will be put into EXTRA_EVENT_END_TIME field of the intent.
allDay Boolean: if the event is an all-day event. Will be put into EXTRA_EVENT_ALL_DAY field of the intent.
flags Int: flags to be set on the intent via Intent#setFlags
Return
Boolean true if the activity is started successfully. false otherwise.

Properties

CONTENT_URI

Added in API level 14
static val CONTENT_URI: Uri!

The content:// style URL for the top-level calendar authority