1
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,联系人还没有排序吗?你能帮我解决这个问题吗? 我用上部()方法也还在Android中排序联系人
光标CUR = cr.query(ContactsContract.Contacts.CONTENT_URI,NULL, NULL,NULL, “上部(” + ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + “)ASC” );
谢谢。我应该使用ArrayList来代替? –
2014-10-18 20:10:33
有没有这样的事情ArrayList? –
2014-10-18 20:12:24
虐待必须使用两个不同的数组列表? – 2014-10-18 20:15:24