try this way hope this helps you
private ArrayList<HashMap<String, String>> GetContact() {
ArrayList<HashMap<String, String>> contacts = new ArrayList<HashMap<String, String>>();
Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
String[] projection = new String[] { ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER, BaseColumns._ID };
Cursor cursor = getContentResolver().query(uri, projection, null, null, null);
if (cursor != null && cursor.moveToFirst()) {
int id = cursor.getColumnIndex(BaseColumns._ID);
int indexName = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME);
int indexPhone = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
do {
HashMap<String, String> item = new HashMap<String, String>();
item.put("id", cursor.getString(id));
item.put("phone", cursor.getString(indexPhone));
item.put("name", cursor.getString(indexName));
contacts.add(item);
} while (cursor.moveToNext());
}
Collections.sort(contacts, new Comparator<HashMap<String, String>>() {
@Override
public int compare(HashMap<String, String> lhs, HashMap<String, String> rhs) {
return lhs.get("name").toLowerCase().compareTo(rhs.get("name").toLowerCase());
}
});
return contacts;
}