title: Android: Database locked, although I have closed it
body: <p>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</p>
  
  <p>Therefore I call this method inside the task in the onSaveInstanceState method:</p>
  
  <pre><code>public void cancelTask() 
  {
      if (dbConn.inTransaction())
          dbConn.endTransaction();
      dbConn.close();
      db.close();
      this.cancel(true);
  }
  </code></pre>
  
  <p>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.</p>
  
  <p>Can anyone tell me how to solve this problem.</p>