title: Android SQLite database exception - code 14 (unable to open database file)
body: <p>I have problem with databases in my android application. I get this exception in many places from different databases:</p>
  
  <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.logtomobile.gmbclient/com.logtomobile.gmbclient.TransactionHistoryActivity}: android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file (code 14)
  </code></pre>
  
  <p>All of my databases are using singleton classes extending SQLiteOpenHelper. I am also closing all cursors after usage. What could be the reason of such exceptions? What can I do to fix this? </p>
  
  <p>Before this exception I got another SQLite exception:</p>
  
  <pre><code>(14) cannot open file at line 32473 of [00bb9c9ce4]
  (14) os_unix.c:32473: (24) open(/data/data/com.logtomobile.gmbclient/databases/GmbDB-journal) 
  </code></pre>
  
  <p>I cannot paste my code, because this exception is thrown every time in a different place in the code. All of the databases are created in the code and not imported from external files. All the methods, whitch are making queries to databases, are called from synchronized methods in DB Helpers. In Helpers there are static Helper instances (singleton), whitch also have member SQLiteDatabase objects. Those objects are initialized once in Helper constructors by getWritableDatabase() and keeped opened always without closing them. Every query in the code is called on those SQLiteDatabase objects.</p>
  
  <pre><code>public synchronized static GmbDBHelper getInstance(Context context) {
      if (sHelper == null) {
          sHelper = new GmbDBHelper(context.getApplicationContext());
      }
  
      return sHelper;
  }
  
  private GmbDBHelper(Context context) {
      super(context, GmbDB.DB_NAME, null, DB_VERSION);
  
      mContext = context;
      mDatabase = getWritableDatabase();
  
      Log.d("DbHelper", "GmbDbHelper()");
  }
  
  synchronized SQLiteDatabase openDbForReading() {
      return mDatabase;
  }
  
  synchronized SQLiteDatabase openDbForWriting() {
      return mDatabase;
  }
  
  ...
  </code></pre>