I know how to get contact names and numbers in a cursor, but when I put them on a listview I get multiple numbers for the same contact in separate lines, i.e. if a contact has more than one number, all these numbers are displayed. How can I select only one number for each contact?
Uri uri = Phone.CONTENT_URI;
String[] projection = { Phone.DISPLAY_NAME, Phone.NUMBER, Phone._ID };
String sortOrder = Phone.DISPLAY_NAME + " COLLATE LOCALIZED ASC";
Cursor cursor = managedQuery(uri, projection, null, null, sortOrder);
Thanks for any help in advance!
If I got you right, and you want to show only one number per
DISPLAY_NAMEdisregarding all others, you can use this hack:edit Short explanation: it’s kind of sql-injection: it will insert 1 in
WHEREpart of the query, making it always true, and addGROUP BY, unsupported bymanagedQuery()