1

I have an Activity which creates and runs a task, inside this task a database connection is created. Then I start a transaction and do some operations on the database. I want that when an orientation change appears the task gets canceled and restarted after the change

Therefore I call this method inside the task in the onSaveInstanceState method:

public void cancelTask() 
{
    if (dbConn.inTransaction())
        dbConn.endTransaction();
    dbConn.close();
    db.close();
    this.cancel(true);
}

But when I restart the task in the task in the onRestoreInstanceState after that is says database is locked. I also noticed that the database connection seems to never be in and transaction.

Can anyone tell me how to solve this problem.

Dreamwalker
  • 3,032
  • 4
  • 30
  • 60
Solidus0815
  • 129
  • 1
  • 1
  • 6
  • Have you checked [this](http://stackoverflow.com/questions/7930139/android-database-locked)? Looks like a duplicate question. Anyway, try that accepted answer and see if it works – Fernando Carvalhosa May 27 '14 at 22:17

0 Answers0