Skip to content Skip to sidebar Skip to footer

How To Create A Contact Programmatically

Possible Duplicate: How to add new contacts in android public boolean createContact(String name, String number, String email) { boolean success = true; try

Solution 1:

ContentValues values = new ContentValues();
            values.put(Data.RAW_CONTACT_ID, 001);
            values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
            values.put(Phone.NUMBER, "            1-800-GOOG-411      ");
            values.put(Phone.TYPE, Phone.TYPE_CUSTOM);
            values.put(Phone.LABEL, "free directory assistance");
            Uri dataUri = getContentResolver().insert(android.provider.ContactsContract.Data.CONTENT_URI, values);

Use the above code. You are not providing id. http://developer.android.com/reference/android/provider/ContactsContract.Data.html


Post a Comment for "How To Create A Contact Programmatically"