嗨,我正在使用 Loader 来获取一些数据。代码如下。
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
return new CursorLoader(this, ContactsContract.PhoneLookup.CONTENT_FILTER_URI,
new String[] { PhoneLookup.TYPE, PhoneLookup.NUMBER,
PhoneLookup.DISPLAY_NAME, PhoneLookup._ID,
PhoneLookup.PHOTO_ID }, null, null, null);
}
我遇到了一个例外。有人能帮我吗
droidRuntime( 2047): java.lang.RuntimeException: An error occured while executing doInBackground()
E/AndroidRuntime( 2047): at android.os.AsyncTask$3.done(AsyncTask.java:278)
E/AndroidRuntime( 2047): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
E/AndroidRuntime( 2047): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
E/AndroidRuntime( 2047): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
E/AndroidRuntime( 2047): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
E/AndroidRuntime( 2047): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
E/AndroidRuntime( 2047): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
E/AndroidRuntime( 2047): at java.lang.Thread.run(Thread.java:856)
E/AndroidRuntime( 2047): Caused by: java.lang.IllegalArgumentException: Invalid column data1
E/AndroidRuntime( 2047): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:166)
E/AndroidRuntime( 2047): at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:136)
E/AndroidRuntime( 2047): at android.content.ContentProviderProxy.query(ContentProviderNative.java:358)
E/AndroidRuntime( 2047): at android.content.ContentResolver.query(ContentResolver.java:311)
E/AndroidRuntime( 2047): at android.content.CursorLoader.loadInBackground(CursorLoader.java:56)
E/AndroidRuntime( 2047): at android.content.CursorLoader.loadInBackground(CursorLoader.java:42)
E/AndroidRuntime( 2047): at android.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:255)
E/AndroidRuntime( 2047): at android.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:66)
E/AndroidRuntime( 2047): at android.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:55)
E/AndroidRuntime( 2047): at android.os.AsyncTask$2.call(AsyncTask.java:264)
E/AndroidRuntime( 2047): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
E/AndroidRuntime( 2047): ... 4 more
当我使用下面的代码时它工作正常
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args)
{
return new CursorLoader(this, ContactsContract.Contacts.CONTENT_URI,
new String[]
{ ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.Contacts.LAST_TIME_CONTACTED }, null,
null, null);
}