title: attempt to re-open an already-closed object: SQLiteDatabase:
body: <p>I'm trying to delete something from a database then insert a new value. I don't know much about databases, so would appreciate advice on whats going wrong here. </p>
  
  <p>I keep getting the following error:</p>
  
  <pre><code>Caused by: java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase:
  </code></pre>
  
  <p>Its called from an async task, works fine the first time, but breaks the second time that the task is triggered. </p>
  
  <p>Here are the important snippets:</p>
  
  <pre><code> public void removeAndInsert(String configRaw) {
      SQLiteDatabase sqlite = null;
      try {
          sqlite = dbHelper.getWritableDatabase();
          removeAndInsert(configRaw, sqlite);
      .....
      finally {
          if (sqlite != null) {
              sqlite.close();
          }
      }
  
  
  
  void removeAndInsert(String configRaw, SQLiteDatabase sqlite) throws SQLException {
      ContentValues initialValues = new ContentValues();
      initialValues.put(DBOpenHelper.CONFIG_CACHE_RAW_DATA, configRaw);
      sqlite.delete(DBOpenHelper.CONFIG_CACHE_TABLE_NAME, null, null);
      sqlite.insert(DBOpenHelper.CONFIG_CACHE_TABLE_NAME, null, initialValues);
  }
  </code></pre>