android 2.2联系人表结构

接触管理与数据操作
本文详细介绍了Android系统中关于联系人管理的API使用方法,包括如何插入、更新、删除和查询联系人数据,以及如何通过操作RawContacts和Data表来实现联系人数据的管理。
                       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(); }

【复现】并_离网风光互补制氢合成氨系统容量-调度优化分析(Python代码实现)内容概要:本文围绕“并_离网风光互补制氢合成氨系统容量-调度优化分析”的主题,提供了基于Python代码实现的技术研究与复现方法。通过构建风能、太阳能互补的可再生能源系统模型,结合电解水制氢与合成氨工艺流程,对系统的容量配置与运行调度进行联合优化分析。利用优化算法求解系统在不同运行模式下的最优容量配比和调度策略,兼顾经济性、能效性和稳定性,适用于并网与离网两种场景。文中强调通过代码实践完成系统建模、约束设定、目标函数设计及求解过程,帮助读者掌握综合能源系统优化的核心方法。; 适合人群:具备一定Python编程基础和能源系统背景的研究生、科研人员及工程技术人员,尤其适合从事可再生能源、氢能、综合能源系统优化等相关领域的从业者;; 使用场景及目标:①用于教学与科研中对风光制氢合成氨系统的建模与优化训练;②支撑实际项目中对多能互补系统容量规划与调度策略的设计与验证;③帮助理解优化算法在能源系统中的应用逻辑与实现路径;; 阅读建议:建议读者结合文中提供的Python代码进行逐模块调试与运行,配合文档说明深入理解模型构建细节,重点关注目标函数设计、约束条件设置及求解器调用方式,同时可对比Matlab版本实现以拓宽工具应用视野。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值