Android: Get google's unique contact ID from ContactProvider database -


i working on requirement, need identify google's contact saved/synced android device's phonebook. have fetch unique contact id (google's unique contact id)of each contact same on other devices , other platform.

i have read android developer's documentation regarding raw_contact_id. also, tried raw contact id, getting different value of raw contact id on other devices.

if can put me on right direction, helpful.

if require more information, please ask.

try using contactscontract.phonelookup

a table represents result of looking phone number, example caller id. perform lookup must append number want find content_filter_uri. query highly optimized.

uri uri = uri.withappendedpath(phonelookup.content_filter_uri, uri.encode(phonenumber));  resolver.query(uri, new string[]{phonelookup.display_name,... 

where

 phonelookup._id 

is you're looking for.

you may try solution provided in this post:

 public static int getcontactidfromnumber(string contactnumber,context context) {     contactnumber = uri.encode(contactnumber);     int phonecontactid = new random().nextint();     cursor contactlookupcursor = context.getcontentresolver().query(uri.withappendedpath(phonelookup.content_filter_uri,contactnumber),new string[] {phonelookup.display_name, phonelookup._id}, null, null, null);         while(contactlookupcursor.movetonext()){             phonecontactid = contactlookupcursor.getint(contactlookupcursor.getcolumnindexorthrow(phonelookup._id));             }         contactlookupcursor.close();      return phonecontactid; } 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -