ContentProvider(联系人)-没有这样的列:metadata_dirty [英] ContentProvider (contacts) - no such column: metadata_dirty
问题描述
我正尝试从电话中获取特定类型的所有联系人,如下所示:
I'm trying to get all contacts of a specific type from the phone like following:
Cursor cursor = context.getContentResolver().query(
ContactsContract.RawContacts.CONTENT_URI,
null,
ContactsContract.RawContacts.ACCOUNT_TYPE + "='com.whatsapp'",
null,
ContactsContract.RawContacts.CONTACT_ID + " ASC");
但是此行已经引发了异常(自定义rom,牛轧糖=>可能与此有关吗?).我只是从一个用户那里收到此错误,而我被困在这里,有人知道如何解决吗?有没有其他查询所有联系人的方法?
But this line already throws an exception (custom rom, nougat => maybe it's related to this?). I only got this error from one user yet and I'm stuck here, does anyone know how to solve that? Is there an alternative way to query all contacts?
我的异常如下:
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)
...
推荐答案
我的查询没有发现任何问题,这似乎是用户自定义ROM中的内部错误.
I don't see anything wrong with your query, it seems like this is an internal bug in the user's custom ROM.
METADATA_DIRTY
是Android N中的新列:
https://developer.android.com/reference/android/provider/ContactsContract.RawContactsColumns.html#METADATA_DIRTY
METADATA_DIRTY
is a new column in Android N:
https://developer.android.com/reference/android/provider/ContactsContract.RawContactsColumns.html#METADATA_DIRTY
因此,似乎系统是Nougat,但Contacts
DB是基于Android
的旧版本.
So it seems like the system is Nougat, but the Contacts
DB is based on an older version of Android
.
这篇关于ContentProvider(联系人)-没有这样的列:metadata_dirty的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!