android 2.2联系人表结构

 

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).
                           

                             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 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(); }

 


 

转载于:https://www.cnblogs.com/haihai88/archive/2011/08/26/6601280.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值