How to get the only phone number from the device contact, not whats app and duo number, etc...
Example: I got the device contact number, but that return
- Phone Number
- What's App Number
- Google Duo Number etc...
Note: I need only a phone number from the local device contact.
val phones: Cursor? = contentResolver.query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?",
arrayOf(contactId),
null
)
// This will return list of contact number
val phoneNumbers: Int = it.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)
Reference:- https://developer.android.com/training/contacts-provider/retrieve-details
The above Link has - ContactsContract.Data.DATA1 that only retrieves the phone number checkout above link for more detail