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.