【发布时间】:2018-05-26 22:40:36
【问题描述】:
我已将我的电话联系人排序并列出到一个数组列表中,但是,我在列表中找到了许多相同联系人姓名的重复项。这是怎么发生的?如何避免这种情况?
这是我尝试过的,
cursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null,
"(" + ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + ") ASC");
while (cursor.moveToNext()) {
try {
name = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
phonenumber = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
contact_names_list.add(name);
phone_num_list.add(phonenumber);
} catch (Exception e) {
e.printStackTrace();
}
谁能帮忙??
【问题讨论】:
-
你可以使用
HASHSET -
有什么例子吗?
-
联系人是否属于多个群组?例如,在 SIM 卡和 Google 通讯录中。
-
是的,一些联系人在一个组中,但不是所有联系人,这里我得到每个联系人姓名的重复超过 2 个。
标签: android sorting android-contacts android-cursor