android 2.2联系人表结构
来源:互联网 发布:多益网络笔试都考什么 编辑:程序博客网 时间:2024/06/09 21:43
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 resources 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).
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 ContactsContract.CommonDataKinds.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 ContactsContract.CommonDataKinds.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_TYPE); values.put(Phone.NUMBER, "1-800-GOOG-411"); values.put(Phone.TYPE, Phone.TYPE_CUSTOM); values.put(Phone.LABEL, "free directory assistance"); Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values); followed are same
ArrayList<ContentProviderOperation> ops = Lists.newArrayList(); ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI).withValue(Data.RAW_CONTACT_ID, rawContactId).withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE).withValue(Phone.NUMBER, "1-800-GOOG-411").withValue(Phone.TYPE, Phone.TYPE_CUSTOM).withValue(Phone.LABEL, "free directory assistance").build()); getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
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<ContentProviderOperation> ops = Lists.newArrayList(); ... int rawContactInsertIndex = ops.size(); ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI) .withValue(RawContacts.ACCOUNT_TYPE, accountType) .withValue(RawContacts.ACCOUNT_NAME, accountName) .build()); ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex) .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) .withValue(StructuredName.DISPLAY_NAME, "Mike Sullivan") .build()); getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
update
data
ArrayList<ContentProviderOperation> ops = Lists.newArrayList(); ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI).withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}).withValue(Email.DATA, "somebody@android.com").build()); getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
delete
data
ArrayList<ContentProviderOperation> ops = Lists.newArrayList(); ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI).withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}).build()); getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
query
data
Cursor c = getContentResolver().query(Data.CONTENT_URI,new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},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(); }
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 resources 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
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 ContactsContract.CommonDataKinds.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 ContactsContract.CommonDataKinds.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_TYPE); values.put(Phone.NUMBER, "1-800-GOOG-411"); values.put(Phone.TYPE, Phone.TYPE_CUSTOM); values.put(Phone.LABEL, "free directory assistance"); Uri dataUri = getContentResolver().insert(Data.CONTENT_URI, values); followed are same
ArrayList<ContentProviderOperation> ops = Lists.newArrayList(); ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI).withValue(Data.RAW_CONTACT_ID, rawContactId).withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE).withValue(Phone.NUMBER, "1-800-GOOG-411").withValue(Phone.TYPE, Phone.TYPE_CUSTOM).withValue(Phone.LABEL, "free directory assistance").build()); getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
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<ContentProviderOperation> ops = Lists.newArrayList(); ... int rawContactInsertIndex = ops.size(); ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI) .withValue(RawContacts.ACCOUNT_TYPE, accountType) .withValue(RawContacts.ACCOUNT_NAME, accountName) .build()); ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI) .withValueBackReference(Data.RAW_CONTACT_ID, rawContactInsertIndex) .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE) .withValue(StructuredName.DISPLAY_NAME, "Mike Sullivan") .build()); getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
update
data
ArrayList<ContentProviderOperation> ops = Lists.newArrayList(); ops.add(ContentProviderOperation.newUpdate(Data.CONTENT_URI).withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}).withValue(Email.DATA, "somebody@android.com").build()); getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
delete
data
ArrayList<ContentProviderOperation> ops = Lists.newArrayList(); ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI).withSelection(Data._ID + "=?", new String[]{String.valueOf(dataId)}).build()); getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);
query
data
Cursor c = getContentResolver().query(Data.CONTENT_URI,new String[] {Data._ID, Phone.NUMBER, Phone.TYPE, Phone.LABEL},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(); }
- android 2.2联系人表结构
- android 2.2联系人表结构
- android 2.2联系人表结构
- Android联系人表结构学习
- android联系人项目结构
- android联系人项目结构
- android 联系人存储结构
- android 联系人存储结构
- Android联系人存储结构
- Android联系人存储结构
- android 联系人信息存储结构
- android-AndroidContacts操作系列之 查看底层联系人表结构
- android2.2联系人表结构
- android2.2联系人表结构
- android联系人信息的存储结构
- android联系人信息的存储结构
- android最新联系人信息的存储结构
- android联系人信息的存储结构
- 如何获取和设置android系统铃声和音量大小
- Item 03 : Use const whenever possible.
- webdynpro中给不同的TAB标签设置数据
- 【那些对传智播客的攻击】第八篇 zuoyi 归来
- php date与gmdate的获取日期的区别
- android 2.2联系人表结构
- Mongo Java Driver中连接数对性能的影响
- MFC 打印和预览的功能 .
- Android display架构分析三-Kernel Space Display架构介绍
- Android display架构分析四-msm_fb.c 函数和数据结构介绍
- 存入数据库的Date类型只有年月日,没有时分秒的原因和解决办法
- The real Jane Austen(真实的简.奥斯丁)
- Eclipse开发环境搭建
- NoSql的多表关联----Mongodb的DBRef的运用