Android 22Contacts表结构
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Android 22Contacts表结构.txt两人之间的感情就像织毛衣,建立的时候一针一线,小心而漫长,拆除的时候只要轻轻一拉。。。。android 2.2联系人表结构
ContactsContract.RawContacts
long _ID read-only Row ID;update rather than to delete and re-insert it.
long CONTACT_ID read-only ContactsContract.Contacts 中的ID
int AGGREGATION_MODE read/write 组合模式;值为AGGREGATION_MODE_DEFAULT, AGGREGATION_MODE_DISABLED 或AGGREGATION_MODE_SUSPENDED.
int DELETED read/write 删除标记;0 or 1;1has been marked for deletion.
int TIMES_CONTACTED read/write 已经联系次数
long LAST_TIME_CONTACTED read/write 上次联系的时间戳
int STARRED read/write 特别友好的联系人;1 if favorite;0 otherwise
int CUSTOM_RINGTONE read/write 与该记录相关的手机铃声
int SEND_TO_VOICEMAIL read/write 当这个Raw来电时,是否转发的语言信箱;1是或0否
String ACCOUNT_NAME read/write-once 账号名
String ACCOUNT_TYPE read/write-once 账号密码
int VERSION read-only 版本;当列或相关数据修改是,将会自动修改
int DIRTY read/write 版本发生改变的标记;同步的 当Raw contact发生改变时,自动设为1(除 URI has the CALLER_IS_SYNCADAPTER外)
ContactsContract.Contacts
long _ID read-only Row ID.建议用LOOKUP_KEY代替
String LOOKUP_KEY read-only 与提示如何找到特定联系的值
long NAME_RAW_CONTACT_ID read-only
long PNOTO_ID read-only ContactsContract.Data table holding the photo. That row has the mime type CONTENT_ITEM_TYPE.
String DISPLAY_NAME_PRIMARY read-only 联系人显示的名字
int IN_VISIBLE_GROUP read-only 这个联系人在UI中是否可见;
int HAS_PHONE_NUMBER read-only 该联系人否至少有一个手机号码
int TIMES_CONTACTED read-only 与该联系人联系的次数
long LAST_TIME_CONTACTED read/write 上次联系的时间戳
String CUSTOM_RINGTONE read/write 与联系人相关的铃声
int STARRED read/write 是否是常用联系人
int SEND_TO_VOICEMAIL read/write
int CONTACT_PRESENCE read-only Contact IM presence status
String CONTACT_STATUS read-only Contact's latest status update. Automatically computed as the latest of all constituent raw contacts' status updates.
long CONTACT_STATUS_TIMESTAMP read-only 插入或修改的最新时间
String CONTACT_STATUS_RES_PACKAGE read-only The package containing resource
s for this status: label and icon
long CONTACT_STATUS_LABEL read-only The resource ID of the label describing the source of contact status, e.g. "Google Talk". This resource is scoped by the CONTACT_STATUS_RES_PACKAGE
long CONTACT_STATUS_ICON read-only The resource ID of the label describing the source of contact status, e.g. "Google Talk". This resource is scoped by the CONTACT_STATUS_RES_PACKAGE.
ContactsContract.Data
long _ID read-only Row ID
String MIMETYPE read/write-once StructuredName.CONTENT_ITEM_TYPE ;Phone.CONTENT_ITEM_TYPE;Email.CONTENT_ITEM_TYPE ;Organization.CONTENT_ITEM_TYPE;Im.CONTENT_ITEM_TYPE ;Nickname.CONTENT_ITEM_TYPE ;Note.CONTENT_ITEM_TYPE;StructuredPostal.CONTENT_ITEM_TYPE;GroupMembership.CONTENT_ITEM_TYPE ;Website.CONTENT_ITEM_TYPE;Event.CONTENT_ITEM_TYPE ;Relation.CONTENT_ITEM_TYPE;
long RAW_CONTACT_ID read/write The id of the row in the ContactsContract.RawContacts table that this data belongs to.
int IS_PRIMARY read/write Whether this is the primary entry of its kind for the raw contact it belongs to. "1" if true, "0" if false.
int IS_SUPER_PRIMARY read/write Whether this is the primary entry of its kind for the aggregate contact it belongs to. Any data record that is "super primary" must also be "primary". For example, the super-primary entry may be interpreted as the default contact value of its kind (for example, the default phone number to use for the contact).
ContactsContract.Groups
long _ID read/write Row ID
String TITLE read/write The display title of this group
String NOTE read/write Notes about the group
int SUMMARY_COUNT read-only The total number of Contacts that have monDataKinds.GroupMembership in this group. Read-only value that is only present when querying CONTENT_SUMMARY_URI.
int SUMMARY_WITH_PHONES read-only The total number of Contacts that have both monDataKinds.GroupMembership in this group, and also have phone numbers. Read-only value that is only present when querying CONTENT_SUMMARY_URI.
int GROUP_VISIBLE read-only 群组是否在数据库中可见1 or 0
int DELETED read/write 删除标记 0,default;1 if the row has been marked for deletion
int SHOULD_SYNC read/write Whether this group should be synced if the SYNC_EVERYTHING settings is false for this group's account.
与联系人相关的操作
insert
data
ContentValues values = new ContentValues(); values.put(Data.RAW_CONTACT_ID, rawContactId); values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_T
YPE); values.put(Phone.NUMBER, "1-800-GOOG-411"); values.put(Phone.TYPE, Phone.TYPE_CUSTOM); values.put(BEL, "free directory assistance"); Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values); followed are same
ArrayList
ContactsContract.RawContacts
ContentValues values = new ContentValues(); values.put(RawContacts.ACCOUNT_TYPE, accountType); values.put(RawContacts.ACCOUNT_NAME, accountName); Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values); long rawContactId = ContentUris.parseId(rawContactUri);
Once ContactsContract.RawContacts.Data values become available, insert those. For example, here's how you would insert a name:
values.clear(); values.put(Data.RAW_CONTACT_ID, rawContactId); values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE); values.put(StructuredName.DISPLAY_NAME, "Mike Sullivan"); getContentResolver().insert(Data.CONTENT_URI, values);
ArrayList
update
data
ArrayList
delete
data
ArrayList
query
data
Cursor c = getContentResolver().query(Data.CONTENT_URI,new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, BEL},Data.RAW_CONTACT_ID + "=?" + " AND "+ Data
.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'", new String[] {String.valueOf(rawContactId)}, null);
ContactsContract.RawContactsEntity
Uri entityUri = ContentUris.withAppendedId(RawContactsEntity.CONTENT_URI, rawContactId); Cursor c = getContentResolver().query(entityUri, new String[]{ RawContactsEntity.SOURCE_ID, RawContactsEntity.DATA_ID, RawContactsEntity.MIMETYPE, RawContactsEntity.DATA1 }, null, null, null); try { while (c.moveToNext()) { String sourceId = c.getString(0); if (!c.isNull(1)) { String mimeType = c.getString(2); String data = c.getString(3); ... } } } finally { c.close(); }
ContactsContract.RawContacts
all raw contacts in a Contact:Cursor c = getContentResolver().query(RawContacts.CONTENT_URI, new String[]{RawContacts._ID}, RawContacts.CONTACT_ID + "=?", new String[]{String.valueOf(contactId)}, null);
To find raw contacts within a specific account, you can either put the account name ....:Uri rawContactUri = RawContacts.URI.buildUpon() .appendQueryParameter(RawContacts.ACCOUNT_NAME, accountName) .appendQueryParameter(RawContacts.ACCOUNT_TYPE, accountType) .build(); Cursor c1 = getContentResolver().query(rawContactUri, RawContacts.STARRED + "<>0", null, null, null); ... Cursor c2 = getContentResolver().query(rawContactUri, RawContacts.DELETED + "<>0", null, null, null);
best for read a raw contact along with all the data associated with: Uri rawContactUri = ContentUris.withAppendedId(RawContacts.CONTENT_URI, rawContactId); Uri entityUri = Uri.withAppendedPath(rawContactUri, Entity.CONTENT_DIRECTORY); Cursor c = getContentResolver().query(entityUri, new String[]{RawContacts.SOURCE_ID, Entity.DATA_ID, Entity.MIMETYPE, Entity.DATA1}, null, null, null); try { while (c.moveToNext()) { String sourceId = c.getString(0); if (!c.isNull(1)) { String mimeType = c.getString(2); String data = c.getString(3); ... } } } finally { c.close(); }