Content Provider之Calendar And Contact Provider

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

Android API Guide

Calendar Provider

下图显示了Calendar的主要Table以及联系他们之间的Fields.
 Calendar Provider data model
其中

namedescription
CalendarContract.Calendars包含日历特定信息,包括名称,颜色,同步信息等等。
CalendarContract.Events事件特定信息,Attendees, reminders, and extended properties 都存储在别的表里. 他们每个都有一个引用EVENT table的_ID的EVENT_ID
CalendarContract.Instances该表持有每一个时间发生的开始和结束时间. 每行代表一个事件的发生. 对于一次性事件,则只有一个instance对应,1:1. 对于重复性事件,则会有多行记录。
CalendarContract.AttendeesThis 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的结构
Contact Structure

  • 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 NameDescription
ACCOUNT_NAME账户名,比如Google的账户名就是用户的Gmail地址
ACCOUNT_TYPE账户类型,比如google的就是com.google。
DELETEDThe “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 。
这里写图片描述

Type-specific names class

Mapping classType of dataNotes
ContactsContract.CommonDataKinds.StructuredNameThe name data for the raw contact associated with this data row.A raw contact has only one of these rows.
ContactsContract.CommonDataKinds.PhotoThe main photo for the raw contact associated with this data row.A raw contact has only one of these rows.
ContactsContract.CommonDataKinds.EmailAn email address for the raw contact associated with this data row.A raw contact can have multiple email addresses.
ContactsContract.CommonDataKinds.StructuredPostalA postal address for the raw contact associated with this data row.A raw contact can have multiple postal addresses.
ContactsContract.CommonDataKinds.GroupMembershipAn 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.
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值