Posted By

macbuntu on 10/15/10


Tagged

insert java contact android


Versions (?)

Android insert new contact


 / Published in: Java
 

  1. private Uri insertContact(Context context, String name, String phone) {
  2.  
  3. ContentValues values = new ContentValues();
  4. values.put(People.NAME, name);
  5. Uri uri = getContentResolver().insert(People.CONTENT_URI, values);
  6. Uri numberUri = Uri.withAppendedPath(uri, People.Phones.CONTENT_DIRECTORY);
  7. values.clear();
  8.  
  9. values.put(Contacts.Phones.TYPE, People.Phones.TYPE_MOBILE);
  10. values.put(People.NUMBER, phone);
  11. getContentResolver().insert(numberUri, values);
  12.  
  13. return uri;
  14. }

Report this snippet  

You need to login to post a comment.