Android API 8 , 10 ContactsContract.Data.HAS_PHONE_NUMBER no such column

折月煮酒 提交于 2019-12-04 11:06:57

The main problem you're running into is that ContactsContract.CommonDataKinds.Phone.CONTENT_URI automatically filters on has_phone_number=1. So you can be guaranteed that everything coming out of Phone.CONTENT_URI does have a phone number. You can then filter that down further by checking if Phone.TYPE is one of Phone.TYPE_MOBILE or Phone.TYPE_WORK_MOBILE (for example) if you want to restrict what type of phone number it has.


For reference (note that has_phone_number is absent from the data/phones URI):

Columns for content://com.android.contacts/contacts:
- times_contacted
- contact_status
- custom_ringtone
- has_phone_number
- phonetic_name
- phonetic_name_style
- contact_status_label
- lookup
- contact_status_icon
- last_time_contacted
- display_name
- sort_key_alt
- in_visible_group
- _id
- starred
- sort_key
- display_name_alt
- contact_presence
- display_name_source
- contact_status_res_package
- contact_status_ts
- photo_id
- send_to_voicemail

and:

Columns for content://com.android.contacts/data/phones:
- data_version
- phonetic_name
- phonetic_name_style
- contact_id
- lookup
- data12
- data11
- data10
- mimetype
- data15
- data14
- data13
- display_name_source
- data_sync1
- data_sync3
- data_sync2
- data_sync4
- account_type
- custom_ringtone
- status
- data1
- data4
- data5
- data2
- data3
- data8
- data9
- group_sourceid
- data6
- account_name
- data7
- display_name
- in_visible_group
- display_name_alt
- contact_status_res_package
- is_primary
- contact_status_ts
- raw_contact_id
- times_contacted
- contact_status
- status_res_package
- status_icon
- contact_status_icon
- mode
- version
- last_time_contacted
- res_package
- _id
- name_verified
- status_ts
- dirty
- is_super_primary
- photo_id
- send_to_voicemail
- name_raw_contact_id
- contact_status_label
- status_label
- sort_key_alt
- starred
- sort_key
- contact_presence
- sourceid
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!