Content Provider之Calendar And Contact Provider

注意:这是一篇草稿,仅作笔记,尚未整理。

Android API Guide

Calendar Provider

下图显示了Calendar的主要Table以及联系他们之间的Fields.
Content Provider之Calendar And Contact Provider_第1张图片
其中

name description
CalendarContract.Calendars 包含日历特定信息,包括名称,颜色,同步信息等等。
CalendarContract.Events 事件特定信息,Attendees, reminders, and extended properties 都存储在别的表里. 他们每个都有一个引用EVENT table的_ID的EVENT_ID
CalendarContract.Instances 该表持有每一个时间发生的开始和结束时间. 每行代表一个事件的发生. 对于一次性事件,则只有一个instance对应,1:1. 对于重复性事件,则会有多行记录。
CalendarContract.Attendees This table holds the event attendee (guest) information. Each row represents a single guest of an event. It specifies the type of guest and the guest’s attendance response for the event.
CalendarContract.Reminders 该表持有警告或通知数据。每行代表一个事件的警告。每个事件可以有多个reminders. 每个事件的最大reminders数量由MAX_REMINDERS指定,该值由sync adapter设定。 Reminder会被事件发生之前的几分钟内被指定,并且有个方法决定如何通知或者警告用户。

Calendar Provider说这么多应该就已经足够了。

Contact Provider

下图是Contact Provider的结构
Content Provider之Calendar And Contact Provider_第2张图片

  • ContactsContract.Contacts table
    Rows representing different people, based on aggregations of raw contact rows.
    每行代表不同的人,给予原始联系人行的聚合。
  • ContactsContract.RawContacts table
    Rows containing a summary of a person’s data, specific to a user account and type.
    每行包含了一个联系人数据的摘要,特别针对一个用户账户和类型。
  • ContactsContract.Data table
    Rows containing the details for raw contact, such as email addresses or phone numbers.
    每行包含了原始联系人的详细信息,诸如:电子邮箱或者电话号码。

Raw contacts

raw contact 代表一个账户和账户名下的一个联系人的数据。由于Contact Provider允许一个联系人来自多个账户,比如微信,本地存储,sim卡,云存储等。
大部分raw contact没有存储在 ContactsContract.RawContacts , 而是存储在ContactsContract.Data table。每个 Data.RAW_CONTACT_ID包含其父类 ContactsContract.RawContacts 的RawContacts._ID。

Column Name Description
ACCOUNT_NAME 账户名,比如Google的账户名就是用户的Gmail地址
ACCOUNT_TYPE 账户类型,比如google的就是com.google。
DELETED The “deleted” flag for a raw contact. 这是用于sync adapter判断是否可以删除服务器端,然后在最终删除本地的

Note:
ContactsContract.RawContacts 中没有存储raw contact的姓名,而是存储在ContactsContract.Data表,在ContactsContract.CommonDataKinds.StructuredName行。
若要使用自己的账户数据,必须使用AccountManager进行注册。

Data

包含了Display name, phone number, email, postal address, photo, and website detail rows.

  1. 带有解释性的columns names

    • RAW_CONTACT_ID
      The value of the _ID column of the raw contact for this data.
    • MIMETYPE
      The type of data stored in this row, expressed as a custom MIME type. The Contacts Provider uses the MIME types defined in the subclasses of ContactsContract.CommonDataKinds. These MIME types are open source, and can be used by any application or sync adapter that works with the Contacts Provider.
    • IS_PRIMARY
      If this type of data row can occur more than once for a raw contact, the IS_PRIMARY column flags the data row that contains the primary data for the type. For example, if the user long-presses a phone number for a contact and selects Set default, then the ContactsContract.Data row containing that number has its IS_PRIMARY column set to a non-zero value.
  2. 通用的column names
    15个通用可访问的从DATA1 through DATA15
    4个用于sync adapter的SYNC1 到SYNC4。

    1. Type-specific column names
      为了帮助与具有特定类型的行之间的工作, Contacts Provider 也提供了类型特定的列名变量,定义在ContactsContract.CommonDataKinds。
      举例:ContactsContract.CommonDataKinds.Email 名称,其类型为 Email.CONTENT_ITEM_TYPE。

下图为ContactsContract.Data行里的descriptive columns and data columns 。
Content Provider之Calendar And Contact Provider_第3张图片

Type-specific names class

Mapping class Type of data Notes
ContactsContract.CommonDataKinds.StructuredName The name data for the raw contact associated with this data row. A raw contact has only one of these rows.
ContactsContract.CommonDataKinds.Photo The main photo for the raw contact associated with this data row. A raw contact has only one of these rows.
ContactsContract.CommonDataKinds.Email An email address for the raw contact associated with this data row. A raw contact can have multiple email addresses.
ContactsContract.CommonDataKinds.StructuredPostal A postal address for the raw contact associated with this data row. A raw contact can have multiple postal addresses.
ContactsContract.CommonDataKinds.GroupMembership An identifier that links the raw contact to one of the groups in the Contacts Provider. Groups are an optional feature of an account type and account name. They’re described in more detail in the section Contact groups.

你可能感兴趣的:(Content Provider之Calendar And Contact Provider)