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

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -