android - Search Contact By Name -
i trying create custom contact app displays contacts have contact number. first of all, there automated way it? suppose not, trying search contact name e.g. rohan.
here code :-
cursor photocursor = getcontentresolver().query( android.provider.contactscontract.contacts.content_uri, new string[] { contactscontract.contacts.photo_id, contactscontract.contacts.display_name }, contactscontract.contacts.display_name + " = ?", new string[]{"rohan"}, null); photocursor.movetofirst(); while (photocursor.movetonext()) { log.d("photo thumbnail", "" + photocursor.getstring(1)); }
although contact exists, not getting log, if remove selection & selection args see rohan in log. doing wrong?
try this:
cursor contactlookupcursor = getcontentresolver().query( uri.withappendedpath(phonelookup.content_filter_uri, uri.encode("rohan")), new string[] {phonelookup.display_name, phonelookup.number}, null, null, null); try { while (contactlookupcursor.movetonext()) { contactname = contactlookupcursor.getstring(contactlookupcursor.getcolumnindexorthrow(phonelookup.display_name)); contactnumber = contactlookupcursor.getstring(contactlookupcursor.getcolumnindexorthrow(phonelookup.number)); } } { contactlookupcursor.close(); }
Comments
Post a Comment