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
Post a Comment