0
我正在嘗試獲取聯繫人的所有電話號碼。當我查詢與光標聯繫的數字時,我得到每個數字的重複。在窺探之後,我認爲這是由於鏈接配置文件(即Google配置文件和電話聯繫人配置文件)。這裏是我的拉出數字代碼:Android聯繫人查詢獲取重複項
Cursor cursor = getContentResolver().query(
Phone.CONTENT_URI,
new String[]{PhoneLookup.NUMBER},
Phone.CONTACT_ID + "=?",
new String[]{id}, null);
while(cursor.moveToNext()) {
String phoneNumber = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
Toast.makeText(getApplicationContext(), phoneNumber, Toast.LENGTH_LONG).show();
}
cursor.close();
有沒有辦法來限制該查詢到某一個人資料? 在此先感謝。我已經搜索了一段時間,並找不到任何解決方案。