android - What is the efficient way to get all contacts names and phone numbers in the contact API -


i use old contacts api (that deprecated on android 2.0), , wondering if way contacts along their's phone number, without making separate query each contact advised in few sites found.

for instance in old api, this:

string[] projection = new string[] { phones._id, phones.name,             phones.number };      uri contacts = phones.content_uri;      cursor managedcursor = managedquery(contacts,              projection, // columns return             null, // rows return (all rows)             null, // selection arguments (none)             // put results in ascending order name             phones.name + " asc"); 

thanks.

i found looking for, , using new api simpler, here new way of querying contact along names , phone number:

cursor managedcursor = getcontentresolver()     .query(contactscontract.commondatakinds.phone.content_uri,      new string[] {phone._id, phone.display_name, phone.number}, null, null,  phone.display_name + " asc"); 

Comments