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