Contact类解析
Contact类 public static class Contacts implements BaseColumns, ContactsColumns, ContactOptionsColumns, ContactNameColumns, ContactStatusColumns
对Contacts表共17项数据:
变量名 列名 备注
_ID _id
LOOKUP_KEY lookup
NAME_RAW_CONTACT_ID参照@1
DISPLAY_NAME display_name 在Contacts对列的描述为DISPLAY_NAME_PRIMARY
PHOTO_ID photo_id
IN_VISIBLE_GROUP in_visible_group
HAS_PHONE_NUMBER has_phone_number
TIMES_CONTACTED times_contacted
LAST_TIME_CONTACTED last_time_contacted
STARRED starred
CUSTOM_RINGTONE custom_ringtone
SEND_TO_VOICEMAIL send_to_voicemail
CONTACT_PRESENCE contact_presence
CONTACT_STATUS contact_status
CONTACT_STATUS_TIMESTAMP contact_status_ts
CONTACT_STATUS_RES_PACKAGE contact_status_res_package
CONTACT_STATUS_LABEL contact_status_label
CONTACT_STATUS_ICON contact_status_icon
注意1:在Contacts对列的描述有NAME_RAW_CONTACT_ID,但没找到相应的变量和列名。
可能ContentResolver觉得把该项暴露给用户每什么意义,就把它隐藏起来了。该项应该是只给系统内部用的哦。
注意2:只有五项是可写TIMES_CONTACTED, LAST_TIME_CONTACTED, STARRED, CUSTOM_RINGTONE, SEND_TO_VOICEMAIL.
Operations
数据插入
A Contact cannot be created explicitly. When a raw contact is inserted, the provider will first try to find a Contact representing the same person.
If one is found, the raw contact's CONTACT_ID column gets the _ID of the aggregate Contact.
If no match is found, the provider automatically inserts a new Contact
and puts its _ID into the CONTACT_ID column of the newly inserted raw contact.
用户部能直接插入数据。数据的插入是由系统自动来完成的。
当raw contact易做图入或时,系统就会检查是否可以把该raw contact加到已经有的组(contact)。
如果找到可以加入的组,就把组ID写到raw contact的CONTACT_ID这个数据项中。
如果没找到就由系统重新创建一组,并把组ID写到raw contact的CONTACT_ID这个数据项中。
如果raw contact的structured name, organization, phone number, email address, or nickname被改变。
系统就会检查raw contact是否还属于raw contact的CONTACT_ID标记的那个组。
如果发现raw contact不属于raw contact的CONTACT_ID标记的那个组。
那么系统就会找是否可以把该raw contact加到已经有的其他组(contact)
如果找到可以加入的组,就把组ID写到raw contact的CONTACT_ID这个数据项中。
如果没找到就由系统重新创建一组,并把组ID写到raw contact的CONTACT_ID这个数据项中。
注意:这的组是指contact(Aggregation of raw contact)
数据更新
自动更新:当contact所包含的RawContacts的信息发生改变时,系统会对contact做相应的更新。
手动强制更新:
Only certain columns of Contact are modifiable: TIMES_CONTACTED, LAST_TIME_CONTACTED, STARRED, CUSTOM_RINGTONE, SEND_TO_VOICEMAIL. Changing any of these columns on the Contact also changes them on all constituent raw contacts.
只有五项是可被用户直接更新。它们是TIMES_CONTACTED, LAST_TIME_CONTACTED, STARRED, CUSTOM_RINGTONE, SEND_TO_VOICEMAIL。
当它们被手动强制更新时,contact所包含的RawContacts的相应项也会被一起更新。
数据删除
Contacts文档说:
Be careful with deleting Contacts! Deleting an aggregate contact deletes all constituent raw contacts.
The corresponding sync adapters will notice the deletions of their respective raw contacts
and remove them from their back end storage.
删除一个Contacts,会把它所包含所有raw contacts都删除掉。
但是用下面语句居然删除不了任何Contacts.
getContentResolver().delete(Contacts.CONTENT_URI, null,
null);
不过在删除Contacts的所有raw contacts后,Contacts也被删除了。
Query
* If you need to read an individual contact, consider using CONTENT_LOOKUP_URI instead of CONTENT_URI.
补充:移动开发 , Android ,