How to add custom data/field in contacts in android 2.0?
I'm trying to write an application where a user can enter his name, phone number, Facebook ID/ Twitter ID etc...which will then be added to the existing contacts application.
Name, phone number - by default exists in the contacts app. How can I go about adding the Facebook ID or Twitter ID? I mean custom fields in the contacts application from my application.
Asked by: David742 | Posted: 24-01-2022
You can easily do that by inserting you own mimetype:
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 read your own data from your own application easily using (query) method and you pass you mimetype in the search criteria.
Also if you want to update an already existed contact, you just need to add new mimtype to that contact.Answered by: Lucas402 | Posted: 25-02-2022
I have another suggestion also: you can add facebook information as IM address, by using the following code:
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")
in this case you can also see it in the Contacts application, not only in your application.Answered by: Tess103 | Posted: 25-02-2022
Still can't find your answer? Check out these communities...
Android Google Support | Android Community | Android Community (Facebook) | Dev.io Android