开发者

update a contact email addresses

开发者 https://www.devze.com 2023-02-14 05:46 出处:网络
I can update a google contact (home) email with the following statement: String select = ContactsContract.Data.CONTACT_ID + \"=? AND \" + ContactsContract.Data.MIMETYPE + \"=\'\"+

I can update a google contact (home) email with the following statement:

    String select = ContactsContract.Data.CONTACT_ID + "=? AND " + ContactsContract.Data.MIMETYPE + "='"  +
    ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE + "'" + " AND " + ContactsContract.CommonDataKinds.Email.TYPE + "=?";     
    String[] args = new String[]{m_sID, String.valueOf(ContactsContract.CommonDataKinds.Email.TYPE_HOME)};      
    m_ops.add(ContentProviderOperation.newUpdate(ContactsContract.Data.CONTENT_URI)             
            .withSelec开发者_开发技巧tion(select, args)             
            .withValue(ContactsContract.CommonDataKinds.Email.DATA, "xxxxx@xxxx.com")             
            .build());      

But how can I update a phone book contacts different email addresses?

Thanks


Use TYPE_WORK, TYPE_OTHER or TYPE_MOBILE instead of TYPE_HOME, depending on which one you want to update. You can also use TYPE_CUSTOM, but you should then add

+ " AND " + ContactsContract.CommonDataKinds.Email.LABEL + "=?"

to your select and the desired label to your args.


The only email filer condition that you have applied is for email with type HOME. ContactsContract.CommonDataKinds.Email.TYPE_HOME which needs to be removed i.e dont apply the filter " AND " + ContactsContract.CommonDataKinds.Email.TYPE + "=?"

0

精彩评论

暂无评论...
验证码 换一张
取 消