@YuviDroid

I'm trying the following at the moment: the open() only gets called in
both onCreate() methods with:

        mDb = new DbAdapter(this);
        if(mDb.getDatabase() == null || !mDb.getDatabase().isOpen()) {
          mDb.open();
        }

The problem I'm having with this is, that there is always a new
DbAdapter created which is fine when the activity is created the first
time. But this way "mDb.getDatabase() == null" will be always true
because its a new mDb.

So I either need to find a way to check if the database is opened
without "mDb" or need to remember mDb even if the activity is stopped.

@Kostya Vasilyev

I tried that, but then my app crashes while switching between
activities. When I was searching for the error I put logs in the
open() and close() methods by my DbAdapter and I could see the
following:

 * open()  (app, activity1 started)
 * open()  (i hit a button in activity1, activity2 is starting and
open is called within onStart)
 * close()  (activity1 is stopped, in onStop close is called)

When I go back to activity1 it throws an exception because the
database is closed. -.-

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to