Search for a contact by phone number

I get the contact details for this phone number using the following code:

Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNum));
Cursor cursor = context.getContentResolver().query(uri,null,null,null,null);

There is a case where the cursor contains 3 entries with the same phone number and display name.

Can you offer an explanation or a possible reason for this?

Many thanks.

+3
source share
1 answer

Are you sure that you do not have the same number for three different contacts or three different contact methods? You can have several contacts with the same numbers and manually combine them in the contacts application.

The generated URI is a request for the contact content provider, so in the above case, you can return more than one contact for this number.

+1

Source: https://habr.com/ru/post/1757224/


All Articles