*bump* I have tried a similar example from the Android site: http://code.google.com/android/samples/NotePad/index.html
Which causes the same error when you manage to switch view from landscape to portrait or otherwise cause onDestroy to be called just as the ListView is being populated with data, thus causing this exception: 01-14 15:20:51.751: ERROR/AndroidRuntime(14633): java.lang.IllegalStateException: attempt to acquire a reference on a close SQLiteClosable 01-14 15:20:51.751: ERROR/AndroidRuntime(14633): at android.database.sqlite.SQLiteClosable.acquireReference (SQLiteClosable.java:31) 01-14 15:20:51.751: ERROR/AndroidRuntime(14633): at android.database.sqlite.SQLiteProgram.compile(SQLiteProgram.java:109) 01-14 15:20:51.751: ERROR/AndroidRuntime(14633): at android.database.sqlite.SQLiteQuery.requery(SQLiteQuery.java:130) 01-14 15:20:51.751: ERROR/AndroidRuntime(14633): at android.database.sqlite.SQLiteCursor.requery(SQLiteCursor.java:389) 01-14 15:20:51.751: ERROR/AndroidRuntime(14633): at android.database.CursorWrapper.requery(CursorWrapper.java:214) 01-14 15:20:51.751: ERROR/AndroidRuntime(14633): at android.widget.CursorAdapter$ChangeObserver.onChange (CursorAdapter.java:327) 01-14 15:20:51.751: ERROR/AndroidRuntime(14633): at android.database.ContentObserver$NotificationRunnable.run (ContentObserver.java:43) 01-14 15:20:51.751: ERROR/AndroidRuntime(14633): at android.os.Handler.handleCallback(Handler.java:542) 01-14 15:20:51.751: ERROR/AndroidRuntime(14633): at android.os.Handler.dispatchMessage(Handler.java:86) 01-14 15:20:51.751: ERROR/AndroidRuntime(14633): at android.os.Looper.loop(Looper.java:123) 01-14 15:20:51.751: ERROR/AndroidRuntime(14633): at android.app.ActivityThread.main(ActivityThread.java:3742) 01-14 15:20:51.751: ERROR/AndroidRuntime(14633): at java.lang.reflect.Method.invokeNative(Native Method) 01-14 15:20:51.751: ERROR/AndroidRuntime(14633): at java.lang.reflect.Method.invoke(Method.java:515) 01-14 15:20:51.751: ERROR/AndroidRuntime(14633): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:739) 01-14 15:20:51.751: ERROR/AndroidRuntime(14633): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497) 01-14 15:20:51.751: ERROR/AndroidRuntime(14633): at dalvik.system.NativeStart.main(Native Method) On Jan 14, 9:59 am, Torgny <torgny.bj...@gmail.com> wrote: > Hello, > > I have a ListView that uses SimpleCursorAdapter with a ViewBinder. > > If switch from portrait to landscape on the phone as the list is > populating items, I get an SQLiteClosable exception because the > activity's onDestroy has been called, but the adapter is still loading > data from the cursor. Is there a better way of handling this? Are > there any events I can listen for on the adapter so I can manually > close the cursor once the data is loaded? > > Here is my current code: > > Cursor cursor = managedQuery(Table.CONTENT_URI, PROJECTION, null, > null, Table.DEFAULT_SORT_ORDER); > SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, > R.layout.list_item, > cursor, new String[] { > Table.AUTHOR_ID, Table.MESSAGE, Table.SENT_DATE > }, new int[] { > R.id.list_item_screen_name, R.id.list_item_text, > R.id.list_item_date > }); > adapter.setViewBinder(new ExampleBinder()); > mMessageList.setAdapter(adapter); > > I switched to getContentResolver().query() to avoid the crashes, but > then I am responsible for closing the cursor myself. If I run this in > a thread, is there any way I can have a listener that closes the query > down once it's finished loading data? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---