【发布时间】:2014-10-18 19:36:04
【问题描述】:
public void ReadContacts() {
Cursor people = getContentResolver().query(Phone.CONTENT_URI, null, null, null,Phone.DISPLAY_NAME + " ASC ");
int indexName = people
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME);
int indexNumber = people
.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
people.moveToFirst();
do {
name = people.getString(indexName);
number = people.getString(indexNumber);
contacts.put(name, number);
} while (people.moveToNext());
printHashMap(contacts);
}
public void printHashMap(HashMap<String, String> a) {
for (Entry<String, String> lists : a.entrySet()) {
Log.d(lists.getKey(), lists.getValue());
}
}
尽管使用了 ASC,但联系人没有排序?你能帮我找出原因吗? 我也使用了 upper() 方法
光标 cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, "upper("+ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + ") ASC");
【问题讨论】: