我正在尝试从手机中获取特定类型的所有联系人,如下所示:
Cursor cursor = context.getContentResolver().query(
ContactsContract.RawContacts.CONTENT_URI,
null,
ContactsContract.RawContacts.ACCOUNT_TYPE + "='com.whatsapp'",
null,
ContactsContract.RawContacts.CONTACT_ID + " ASC");
但是这条线已经抛出了一个异常(custom rom, nougat => 也许它与此有关?)。我只从一个用户那里得到了这个错误,我被困在这里,有谁知道如何解决这个问题?是否有其他方法可以查询所有联系人?
我的异常如下所示:
Exception: android.database.sqlite.SQLiteException: no such column: metadata_dirty (code 1): , while compiling:
SELECT sort_key, send_to_voicemail, pinned, display_name, metadata_dirty,
phonebook_label_alt, version, phonebook_bucket, _id, custom_ringtone,
times_contacted, account_type_and_data_set, sync4, dirty, sync2,
contact_id, raw_contact_is_user_profile, aggregation_mode, data_set,
phonebook_label, account_type, sync3, display_name_alt, phonetic_name,
last_time_contacted, display_name_source, backup_id, sort_key_alt,
phonebook_bucket_alt, deleted, starred, account_name, sync1, sourceid,
phonetic_name_style
FROM view_raw_contacts_restricted AS view_raw_contacts
WHERE (1)
AND ((account_type='com.whatsapp'))
ORDER BY contact_id ASC
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java)
at android.content.ContentProviderProxy.query(ContentProviderNative.java)
at android.content.ContentResolver.query(ContentResolver.java)
at android.content.ContentResolver.query(ContentResolver.java)
...