Question

How can i add two or more addresses using contacts contract? I have three postal addresses to add but i don't see any secondary_address like one for phone/Email. Can anybody assist me with this? Thanks!!

Was it helpful?

Solution

This worked for me.

where listSize -> number of contacts

for (int i = 0; i < listSize; i++) {

            values.clear();
            values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
            values.put(Phone.IS_PRIMARY, true);
            values.put(Phone.TYPE, Phone.TYPE_CUSTOM);
            values.put(Phone.LABEL, "Work "+(i+1));
            values.put(Data.RAW_CONTACT_ID, rawContactId);
            values.put(Phone.NUMBER, allContacts.get(wanted.get(i)).getPhone());
            getContentResolver().insert(Data.CONTENT_URI, values);  

            values.clear();
            values.put(Data.MIMETYPE, StructuredPostal.CONTENT_ITEM_TYPE);
            values.put(StructuredPostal.TYPE, Phone.TYPE_CUSTOM);
            values.put(StructuredPostal.LABEL, "Work "+(i+1));
            values.put(Data.RAW_CONTACT_ID, rawContactId);
            values.put(StructuredPostal.STREET, allContacts.get(wanted.get(i)).street);
            values.put(StructuredPostal.CITY, allContacts.get(wanted.get(i)).city);
            values.put(StructuredPostal.REGION, allContacts.get(wanted.get(i)).state);
            values.put(StructuredPostal.POSTCODE, allContacts.get(wanted.get(i)).zipCode);
            getContentResolver().insert(Data.CONTENT_URI, values);
        }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top