Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

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.

like image 688
Giridhar Avatar asked Sep 05 '25 03:09

Giridhar


1 Answers

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.

like image 148
Bassel Kh Avatar answered Sep 08 '25 00:09

Bassel Kh