无法插入Android通讯录地址 [英] Not able to insert address of contacts in android
问题描述
我可以插入新的Android联系人的姓名,他所有的电话号码,并在Android的所有电子邮件ID。但我不能够插入他的地址。我试了一下使用$以下行C $ CS,同时插入它没有显示出任何错误,但是当我试图打开联系人列表中的联系人,这显示了contact.Please环境误差看看我的$ C $角
I am able to insert new android contact's name, his all phone number and all email ids in android. But i am not able to insert his address. I tried it using following lines of codes, It did not show any error while inserting, but when i tried to open the contacts in Contacts list, it shows environment error for that contact.Please have a look at my code.
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
ops.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
.withValue(ContactsContract.Data.MIMETYPE,
ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE)
.withValue(ContactsContract.CommonDataKinds.StructuredPostal.POBOX, poBox)
.withValue(ContactsContract.CommonDataKinds.StructuredPostal.STREET, street)
.withValue(ContactsContract.CommonDataKinds.StructuredPostal.REGION, state)
.withValue(ContactsContract.CommonDataKinds.StructuredPostal.CITY, city)
.withValue(ContactsContract.CommonDataKinds.StructuredPostal.POSTCODE, postalCode)
.withValue(ContactsContract.CommonDataKinds.StructuredPostal.COUNTRY, country)
.withValue(ContactsContract.CommonDataKinds.StructuredPostal.TYPE, type)
.build());
下面信箱,街道,州,城市,邮政code,国家,所有类型越来越值。
Here poBox,street,state,city,postalCode,country ,type all are getting values.
推荐答案
您MIME类型是错误的。
它应该是android.provider.ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE
Your Mime type is wrong. It should be android.provider.ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE
这篇关于无法插入Android通讯录地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!