android - get only last mobile number entered/edited for each contact id in phonebook -


i using code phone contacts. getting multiple names based on how many mobile/work numbers have entered . want 1 contact id last edited/added mobile number .is there way can edit following query achieve result ? appreciate help.

   cursor cur = managedquery(contactscontract.data.content_uri, null, contactscontract.contacts.data.mimetype + "='" + contactscontract.commondatakinds.phone.content_item_type + "'", null,                     contactscontract.data.display_name + " asc");           int number = mcursor.getcolumnindex(contactscontract.commondatakinds.phone.number);         int name = mcursor.getcolumnindex(contactscontract.data.display_name);            while (mcursor.movetonext()) {             string phname = mcursor.getstring(name);             string phnumber = mcursor.getstring(number);              string thumbnailuri = mcursor.getstring(mcursor.getcolumnindex(contactscontract.contacts.photo_thumbnail_uri));  } 

try using modified date

cursor cur = managedquery(contactscontract.data.content_uri, null, contactscontract.contacts.data.mimetype + "='" + contactscontract.commondatakinds.phone.content_item_type + "'", null, contactscontract.data.contact_last_updated_timestamp + " desc");      int _id = mcursor.getcolumnindex(contactscontract.data.contact_id);     int number = mcursor.getcolumnindex(contactscontract.commondatakinds.phone.number);     int name = mcursor.getcolumnindex(contactscontract.data.display_name);        while (mcursor.movetonext()) {         int id = mcursor.getstring(_id);         string phname = mcursor.getstring(name);         string phnumber = mcursor.getstring(number);          string thumbnailuri = mcursor.getstring(mcursor.getcolumnindex(contactscontract.contacts.photo_thumbnail_uri));      } 

check queue. if id same similar name contacts group them. let me know after trying this


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -