Answer the question
In order to leave comments, you need to log in
How to resolve IllegalStateException error in ListView + ContentProvider + CursorAdapter + Loader?
I am using ContentProvider + CursorAdapter + Loader.
In a separate thread, I load data from the network, parse it and add it to the database through the ContentProvider:
context.getContentResolver().insert(uri, contentValues);
@Override
public void onLoadFinished(Loader loader, Cursor cursor) {
cursorAdapter.swapCursor(cursor);
cursorAdapter.notifyDataSetChanged();
}
java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. [in ListView(-1, class com.madyar_android.app.PullToRefresh$4) with Adapter(class com.madyar_android.app.PullToRefresh$PullToRefreshAdapter)]
at android.widget.ListView.layoutChildren(ListView.java:1548)
at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:4320)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:776)
at android.view.Choreographer.doCallbacks(Choreographer.java:579)
at android.view.Choreographer.doFrame(Choreographer.java:547)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:762)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:5297)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Answer the question
In order to leave comments, you need to log in
They write that
Make sure the content of your adapter is not modified from a background thread, but only from the UI thread
The information in the adapter was updated (changed), but it did not notify the ListView about it. adapter.notifyDataSetchanged()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question