I'm trying to get all of the phone numbers for a contact. When I query the numbers associated with a contact with a cursor, I get duplicates of every number. After snooping around I believe that this is because of the Linked Profiles (i.e. Google profile and Phone Contacts profile). Here is my code for pulling out the numbers:
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();
Is there a way to limit this query to a certain profile? Thanks in advance. I've searched on this for awhile and been unable to find any solutions.