How can i get all phone numbers from call log to a custom List view in Android? -
i want access phone numbers android phone call log custom listview. custom listview created , working fine accessing phone numbers phone contacts. body please explain ?
try contentresolver cr = getcontentresolver(); cursor cur = cr.query(contactscontract.contacts.content_uri, null, null, null, null); if (cur.getcount() > 0) { while (cur.movetonext()) { string id = cur.getstring(cur.getcolumnindex(contactscontract.contacts._id)); string name = cur.getstring(cur.getcolumnindex(contactscontract.contacts.display_name)); if (integer.parseint(cur.getstring( 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)); toast.maketext(articleactivity.this, "name: " + name + ", phone no: " + phoneno, toast.length_short).show(); } pcur.close(); } } }
Comments
Post a Comment