Home » Android » android – How to add new field(s) to the contact?

android – How to add new field(s) to the contact?

Posted by: admin May 14, 2020 Leave a comment


I want to add a Custom field to the ContactsContract content provider. I’m trying to build a Voip application and would like to add a SIP address([email protected]) field to it. What MIME type will I need to associate with it?
Also I want to add a group address field which will have a list of group addresses in it ([email protected], [email protected],…). Wich MIME type will I have to associate with this type of field.

I also want to add custom fields to the Call History like a session ID and SIP address([email protected]) field. How can I customize the call history?

It’ll be great if someone can give me an example.

How to&Answers:

You have to creat your own mime type for those.

Here is an example that saves a boolean as my custom mime type to the contacts. It uses the latest SDK 2.1

public void saveFormality() {
        try {
            ContentValues values = new ContentValues();
            values.put(Data.DATA1, this.getFormality() ? "1" : "0");
            int mod = ctx.getContentResolver().update(
                    Data.CONTACT_ID + "=" + this.getId() + " AND "
                            + Data.MIMETYPE + "= '"
                            + clsContacts.FORMALITY_MIMETYPE + "'", null);

            if (mod == 0) {
                values.put(Data.CONTACT_ID, this.getId());
                values.put(Data.MIMETYPE, clsContacts.FORMALITY_MIMETYPE);
                ctx.getContentResolver().insert(Data.CONTENT_URI, values);
        } catch (Exception e) {
            Log.v(TAG(), "saveFormality failed");