0

I have inserted some raw contacts (given account type and name null). the native contact app of android shows all contacts are sorted ( merged previews and newly given). But in my app (a listview for displaying contacts), it shows first the previous contatcs (sorted by display name) and then newly inserted contacs (also sorted). I have tried whatever combination possible , but no luck. please help any one.

Query Code

String PROJECTION[] = new String[] { ContactsContract.Contacts._ID,
        ContactsContract.Contacts.DISPLAY_NAME};

private final String SORT_ORDER = ContactsContract.Contacts.DISPLAY_NAME + " ASC";

Uri uri = ContactsContract.Contacts.CONTENT_URI;

Cursor contacts = cr.query(uri, PROJECTION, null ,null, SORT_ORDER);

Update*strong text* however , i was using handler , and now after converting to cusorloadr with loader manager. problem solved

shams.arifin
  • 9
  • 1
  • 6

2 Answers2

0

Use getShort() method of Cursor to sort on the bases of a particular column.

Lucifer
  • 29,392
  • 25
  • 90
  • 143
0

try this as query :

Cursor cursor = getContentResolver.query(ContactsContract.Contacts.CONTENT_URI, PROJECTION, null ,null, Phone.DISPLAY_NAME + " ASC");
Chirag Shah
  • 2,058
  • 2
  • 20
  • 30