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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -