I have a ListActivity that uses a CursorAdapter to fill the rows in
the view. I wrote a database helper class that gives me back results
for common queries I make for my app, and it uses an SQLiteOpenHelper
implementation I wrote to open the database. I use the open helper to
open the database and get a cursor to pass to my CursorAdapter. Here's
a code snippet:

public static Cursor getCursor(DbOpenHelper openHelper) {
        SQLiteDatabase db = openHelper.getWritableDatabase();
        db.beginTransaction();
        Cursor c = null;
        try {
                String sql = "select * from " + TABLE_NAME;
            c = db.rawQuery(sql, null);
            db.setTransactionSuccessful();
        } catch (SQLException e) {
                Log.e("Exception on query", e.toString());
            } finally {
                db.endTransaction();
            }

            return c;
    }


The problem I'm having, that I didn't have before I implemented the
open helper (before I just opened the database directly without a
helper), is when I click on an item, which takes me to another
activity, and then go back to this activity. When it initializes
everything is fine, and my list is populated fine, but when I go back
from the activity that follows, the list is empty and in the LogCat I
see "Invalid statement in fillWindow()".

It appears from a few post I've seen that the reason is, when I
requery the cursor, the database is closed. But I'm not closing it!
I'm scratching my head on this one.

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