我試圖從ContactsContract中檢索未標記爲要刪除的電話號碼。檢索未從Android聯繫人列表中刪除的電話號碼
@Override
public Loader onCreateLoader(int id, Bundle args) {
return new CursorLoader(
this,
ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
new String[]{
ContactsContract.CommonDataKinds.Phone.NUMBER
},
ContactsContract.CommonDataKinds.Phone.DELETED + "==0",
null,
null);
}
不過,我得到以下錯誤:
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:304)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: android.database.sqlite.SQLiteException: no such column: deleted (code 1): , while compiling: SELECT DISTINCT data1 FROM view_data data LEFT OUTER JOIN (SELECT data_usage_stat.data_id as STAT_DATA_ID, SUM(data_usage_stat.times_used) as times_used, MAX(data_usage_stat.last_time_used) as last_time_used FROM data_usage_stat GROUP BY data_usage_stat.data_id) as data_usage_stat ON (STAT_DATA_ID=data._id) WHERE (1 AND mimetype_id=5) AND ((deleted==0))
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:181)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:421)
at android.content.ContentResolver.query(ContentResolver.java:478)
at android.content.CursorLoader.loadInBackground(CursorLoader.java:64)
at android.content.CursorLoader.loadInBackground(CursorLoader.java:42)
at android.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:312)
at android.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:69)
at android.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:57)
at android.os.AsyncTask$2.call(AsyncTask.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
The documentation for ContactsContract.CommonDataKinds.Phone.CONTENT_URI指出,數據記錄將與相關的原始接觸和聚集聯繫人數據相結合。但「刪除」不在那裏。爲什麼以及如何才能獲得未被刪除的電話號碼?
有趣的是,它沒有記錄在任何地方..或者我找不到它。確切地說,當您通過ContactsContract.CommonDataKinds.Phone.CONTENT_URI詢問時,您會收到未刪除的電話號碼。 – atakan
檢查下刪除的討論,它不是很直接,但你應該能夠得到圖片https://developer.android.com/reference/android/provider/ContactsContract.RawContacts.html – iago