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
-~----------~----~----~----~------~----~------~--~---

Reply via email to