How to add the new contacts on android 2.2?
-
29-09-2019 - |
Question
I need to add the new contacts on android 2.2 version.
How to add the all fields like Firstname, Lastname, URL, Nickname, IM, Addresses and mobile number?
Solution
Take a look at: http://developer.android.com/resources/articles/contacts.html
The process involves some steps, as you would insert the name contact+name first, then field by field.
Example for phone number:
import android.provider.ContactsContract.CommonDataKinds.Phone;
...
ContentValues values = new ContentValues();
values.put(Phone.RAW_CONTACT_ID, rawContactId);
values.put(Phone.NUMBER, phoneNumber);
values.put(Phone.TYPE, Phone.TYPE_MOBILE);
Uri uri = getContentResolver().insert(Phone.CONTENT_URI, values);
Additionally, have a read here: http://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.html
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow