android get all contacts -


how can names of contacts in android , put them array of strings?

try too,

private void getcontactlist() {     contentresolver cr = getcontentresolver();     cursor cur = cr.query(contactscontract.contacts.content_uri,             null, null, null, null);      if ((cur != null ? cur.getcount() : 0) > 0) {         while (cur != null && cur.movetonext()) {             string id = cur.getstring(                     cur.getcolumnindex(contactscontract.contacts._id));             string name = cur.getstring(cur.getcolumnindex(                     contactscontract.contacts.display_name));              if (cur.getint(cur.getcolumnindex(                     contactscontract.contacts.has_phone_number)) > 0) {                 cursor pcur = cr.query(                         contactscontract.commondatakinds.phone.content_uri,                         null,                         contactscontract.commondatakinds.phone.contact_id + " = ?",                         new string[]{id}, null);                 while (pcur.movetonext()) {                     string phoneno = pcur.getstring(pcur.getcolumnindex(                             contactscontract.commondatakinds.phone.number));                     log.i(tag, "name: " + name);                     log.i(tag, "phone number: " + phoneno);                 }                 pcur.close();             }         }     }     if(cur!=null){         cur.close();     } } 

if need more reference means refer link read contactlist


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -