【发布时间】:2014-02-23 11:41:39
【问题描述】:
在下面的代码中,我正在尝试获取具有特定电话号码的所有联系人。
但是,我似乎总是不止一次地获得一些联系人 ID。 具体来说,我有 2 个具有相同电话号码的联系人,并且我有 3 个联系人 ID。其中一个两次(相同的ID)
有什么想法吗?
谢谢
Cursor contactLookupCursor =
localContentResolver.query(
Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(requestedPhone)),
new String[] {PhoneLookup._ID},
null,
null,
null);
if (contactLookupCursor != null)
{
System.out.println("contactLookupCursor.getCount = "+contactLookupCursor.getCount()); // here i get 3
if(contactLookupCursor.moveToFirst())
{
do
{
int ColumnIndex = contactLookupCursor.getColumnIndex(PhoneLookup._ID);
if(ColumnIndex >= 0)
{
String contactId = contactLookupCursor.getString(ColumnIndex);
System.out.println("contactId="+contactId);// here i get 12 then 13 then 13 again
}
}
while (contactLookupCursor.moveToNext());
}
contactLookupCursor.close();
}
【问题讨论】:
标签: android contacts android-contacts