public static final class CalendarContract.Events
implements BaseColumns, CalendarContract.SyncColumns, CalendarContract.EventsColumns, CalendarContract.CalendarColumns
All operations can be done either as an app or as a sync adapter. To perform an operation as a sync adapter
should be set to true and
must be set in the Uri parameters. See
for details on adding parameters. Sync adapters have write access to more columns but are restricted to a single account at a time.
When inserting a new event the following fields must be included:
There are also further requirements when inserting or updating an event. See the section on Writing to Events.
- dtend if the event is non-recurring
- duration if the event is recurring
- rrule or rdate if the event is recurring
- a calendar_id
To perform an update of an Event the
_ID of the event should be provided either as an appended id to the Uri (
withAppendedId(Uri, long)) or as the first selection item--the selection should start with "_id=?" and the first selectionArg should be the _id of the event. Updates may also be done using a selection and no id. Updating an event must respect the same rules as inserting and is further restricted in the fields that can be written. See the section on Writing to Events.
Events can be deleted either by the
_ID as an appended id on the Uri or using any standard selection. If an appended id is used a selection is not allowed. There are two versions of delete: as an app and as a sync adapter. An app delete will set the deleted column on an event and remove all instances of that event. A sync adapter delete will remove the event from the database and all associated data.
Querying the Events table will get you all information about a set of events except their reminders, attendees, and extended properties. There will be one row returned for each event that matches the query selection, or at most a single row if the
_ID is appended to the Uri. Recurring events will only return a single row regardless of the number of times that event repeats.
Writing to Events
There are further restrictions on all Updates and Inserts in the Events table:
- If allDay is set to 1 eventTimezone must be
TIMEZONE_UTC and the time must correspond to a midnight boundary.
- Exceptions are not allowed to recur. If rrule or rdate is not empty, original_id and original_sync_id must be empty.
- In general a calendar_id should not be modified after insertion. This is not explicitly forbidden but many sync adapters will not behave in an expected way if the calendar_id is modified.
The following Events columns are writable by both an app and a sync adapter.
The following Events columns are writable only by a sync adapter
The remaining columns are either updated by the provider only or are views into other tables and cannot be changed through the Events table.
用于定期事件例外的content：// style URI。 插入需要附加的事件ID。 删除异常需要原始事件ID和异常事件ID（请参阅