How to add user data / field to contacts in android 2.0?

I am trying to write an application in which the user can enter their name, phone number, Facebook ID / Twitter, etc., which will then be added to the existing contacts application.

Name, phone number - by default in the contacts application. How can I add a Facebook id or Twitter id? I mean custom fields in the contacts application from my application.

+3
source share
2 answers

You can easily do this by inserting your own mimetype type:

Builder builder = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID,0)
.withValue(ContactsContract.Data.MIMETYPE,"vnd.android.cursor.item/facebook")
.withValue("data1","bkhashfehFacebookId")

And then you can easily read your own data from your own application using the (query) method, and you will pass mimetype to your search criteria.

, , mimtype .

+5

: facebook IM-, :

Builder builder = ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI)
.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID,0)
.withValue(ContactsContract.Data.MIMETYPE,"ContactsContract.CommonDataKinds.Im.CONTENT_ITEM_TYPE")
.withValue(ContactsContract.CommonDataKinds.Im.DATA,"bkhashfehFacebookId")
.withValue(ContactsContract.CommonDataKinds.Im.TYPE,ContactsContract.CommonDataKinds.Im.TYPE_WORK)
.withValue(ContactsContract.CommonDataKinds.Im.PROTOCOL,ContactsContract.CommonDataKinds.Im.CUSTOM_PROTOCOL)
.withValue(ContactsContract.CommonDataKinds.Im.CUSTOM_PROTOCOL,"FaceBook")

"" .

+2

Source: https://habr.com/ru/post/1726478/


All Articles