title: Android SQCipher do I need to close the database?
body: <p>I've read a lot about using a standard SQLiteDatabase in android and it seems that the best way is to keep one instance of SQLiteOpenHelper and never close the returned SQLiteDatabase object, nor SQLiteOpenHelper. 
  The question is whether those guidelines are valid when using SQCipher encryption library? 
  It seems the close() method of SQLiteOpenHelper in SQCipher package is not empty and do release some stuff. Is it safe to never call this method?</p>
  
  <p>Below is the actual code of SQLiteDatabase.close() method from Github (<a href="http://goo.gl/u4L0C" rel="nofollow">http://goo.gl/u4L0C</a>):</p>
  
  <pre><code>public void close() {
  
      if (!isOpen()) {
          return; // already closed
      }
      lock();
      try {
          closeClosable();
          // close this database instance - regardless of its reference count value
          onAllReferencesReleased();
      } finally {
          unlock();
      }
  }
  
  private void closeClosable() {
      /* deallocate all compiled sql statement objects from mCompiledQueries cache.
       * this should be done before de-referencing all {@link SQLiteClosable} objects
       * from this database object because calling
       * {@link SQLiteClosable#onAllReferencesReleasedFromContainer()} could cause the database
       * to be closed. sqlite doesn't let a database close if there are
       * any unfinalized statements - such as the compiled-sql objects in mCompiledQueries.
       */
      deallocCachedSqlStatements();
  
      Iterator&lt;Map.Entry&lt;SQLiteClosable, Object&gt;&gt; iter = mPrograms.entrySet().iterator();
      while (iter.hasNext()) {
          Map.Entry&lt;SQLiteClosable, Object&gt; entry = iter.next();
          SQLiteClosable program = entry.getKey();
          if (program != null) {
              program.onAllReferencesReleasedFromContainer();
          }
      }
  }
  </code></pre>