title: SQLiteCantOpenDatabaseException: unknown error (code 14) Could not open database
body: <p>I'm getting this error when I'm trying to get a readable or writable database.
  "SQLiteCantOpenDatabaseException: unknown error (code 14) Could not open database"
  I'm having this weird problem with SQLiteOpenHelper and I've seen some similars answer about this same issue here but none of them solved my problem.
  As desperate as I am, I'm posting my code below in hope some one find something I'm not seeing...</p>
  
  <p>(One important information: I get this app from another working one. But the very firt time I debug it, I still have not changed the the dbname. Which was with the name of the previous app (ks.db). This db exists at my debug device but  tr.db doesn't)</p>
  
  <p>My DatabaseHelper class is like this:</p>
  
  <pre><code>//Singleton
  private static DatabaseHelper sInstance;
  
  //Log
  private static String TAG = "Database";
  
  private static final String NAME_DB = "tr.db";
  private static final String PATH_DB_DEBUG = "/mnt/sdcard/";
  private static final int VERSION = 4;
  
  //TABLE NAMES
  private static final String TABLE_USERS = "users";
  private static final String TABLE_TRACKS = "tracks";
  private static final String TABLE_ROTAS = "rotas";
  ...
  /**
       *
       * @param context
       * @return Unique instance of DataBaseHelper
       */
      public static synchronized DatabaseHelper getInstance(Context context) {
          if (sInstance == null) {
              sInstance = new DatabaseHelper(context.getApplicationContext());
          }
          return sInstance;
      }
  </code></pre>
  
  <p>my android manifest:</p>
  
  <p>...</p>
  
  <p><code>&lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;</code>
  ...</p>
  
  <p>And in the main activity:</p>
  
  <pre><code>    //DB
      DatabaseHelper database;
  ...
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  ...
          //database
          database = DatabaseHelper.getInstance(this.getApplicationContext());
          database.getReadableDatabase(); ( &lt;- Error HERE)
  </code></pre>
  
  <p>This is the full error stack:</p>
  
  <pre><code>&gt; 12-13 15:02:43.798    5764-5764/com.snitram.toriders E/SQLiteLog﹕ (14)
  &gt; cannot open file at line 31307 of [2ef4f3a5b1] 12-13 15:02:43.798   
  &gt; 5764-5764/com.snitram.toriders E/SQLiteLog﹕ (14) os_unix.c:31307: (2)
  &gt; open(/storage/emulated/0tr.db) - 12-13 15:02:43.811   
  &gt; 5764-5764/com.snitram.toriders E/SQLiteDatabase﹕ Failed to open
  &gt; database '/storage/emulated/0tr.db'.
  &gt;     android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
  &gt;             at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
  &gt;             at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:207)
  &gt;             at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:191)
  &gt;             at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
  &gt;             at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
  &gt;             at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
  &gt;             at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:806)
  &gt;             at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:791)
  &gt;             at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
  &gt;             at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:571)
  &gt;             at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:269)
  &gt;             at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223)
  &gt;             at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:187)
  &gt;             at com.snitram.toriders.activities.LoginActivity.onCreate(LoginActivity.java:222)
  &gt;             at android.app.Activity.performCreate(Activity.java:6245)
  &gt;             at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
  &gt;             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
  &gt;             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
  &gt;             at android.app.ActivityThread.-wrap11(ActivityThread.java)
  &gt;             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
  &gt;             at android.os.Handler.dispatchMessage(Handler.java:102)
  &gt;             at android.os.Looper.loop(Looper.java:148)
  &gt;             at android.app.ActivityThread.main(ActivityThread.java:5443)
  &gt;             at java.lang.reflect.Method.invoke(Native Method)
  &gt;             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
  &gt;             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 12-13
  &gt; 15:02:43.814    5764-5764/com.snitram.toriders E/SQLiteOpenHelper﹕
  &gt; Couldn't open /storage/emulated/0tr.db for writing (will try
  &gt; read-only):
  &gt;     android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
  &gt;             at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
  &gt;             at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:207)
  &gt;             at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:191)
  &gt;             at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
  &gt;             at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
  &gt;             at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
  &gt;             at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:806)
  &gt;             at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:791)
  &gt;             at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
  &gt;             at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:571)
  &gt;             at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:269)
  &gt;             at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223)
  &gt;             at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:187)
  &gt;             at com.snitram.toriders.activities.LoginActivity.onCreate(LoginActivity.java:222)
  &gt;             at android.app.Activity.performCreate(Activity.java:6245)
  &gt;             at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
  &gt;             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
  &gt;             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
  &gt;             at android.app.ActivityThread.-wrap11(ActivityThread.java)
  &gt;             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
  &gt;             at android.os.Handler.dispatchMessage(Handler.java:102)
  &gt;             at android.os.Looper.loop(Looper.java:148)
  &gt;             at android.app.ActivityThread.main(ActivityThread.java:5443)
  &gt;             at java.lang.reflect.Method.invoke(Native Method)
  &gt;             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
  &gt;             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 12-13
  &gt; 15:02:43.815    5764-5764/com.snitram.toriders E/SQLiteLog﹕ (14)
  &gt; cannot open file at line 31307 of [2ef4f3a5b1] 12-13 15:02:43.815   
  &gt; 5764-5764/com.snitram.toriders E/SQLiteLog﹕ (14) os_unix.c:31307: (2)
  &gt; open(/storage/emulated/0tr.db) - 12-13 15:02:43.816   
  &gt; 5764-5764/com.snitram.toriders E/SQLiteDatabase﹕ Failed to open
  &gt; database '/storage/emulated/0tr.db'.
  &gt;     android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
  &gt;             at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
  &gt;             at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:207)
  &gt;             at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:191)
  &gt;             at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
  &gt;             at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
  &gt;             at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
  &gt;             at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:806)
  &gt;             at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:791)
  &gt;             at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
  &gt;             at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:234)
  &gt;             at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:187)
  &gt;             at com.snitram.toriders.activities.LoginActivity.onCreate(LoginActivity.java:222)
  &gt;             at android.app.Activity.performCreate(Activity.java:6245)
  &gt;             at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
  &gt;             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
  &gt;             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
  &gt;             at android.app.ActivityThread.-wrap11(ActivityThread.java)
  &gt;             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
  &gt;             at android.os.Handler.dispatchMessage(Handler.java:102)
  &gt;             at android.os.Looper.loop(Looper.java:148)
  &gt;             at android.app.ActivityThread.main(ActivityThread.java:5443)
  &gt;             at java.lang.reflect.Method.invoke(Native Method)
  &gt;             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
  &gt;             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 12-13
  &gt; 15:02:43.816    5764-5764/com.snitram.toriders D/AndroidRuntime﹕
  &gt; Shutting down VM 12-13 15:02:43.817    5764-5764/com.snitram.toriders
  &gt; E/AndroidRuntime﹕ FATAL EXCEPTION: main
  &gt;     Process: com.snitram.toriders, PID: 5764
  &gt;     java.lang.RuntimeException: Unable to start activity ComponentInfo{com.snitram.toriders/com.snitram.toriders.activities.LoginActivity}:
  &gt; android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error
  &gt; (code 14): Could not open database
  &gt;             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2426)
  &gt;             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
  &gt;             at android.app.ActivityThread.-wrap11(ActivityThread.java)
  &gt;             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
  &gt;             at android.os.Handler.dispatchMessage(Handler.java:102)
  &gt;             at android.os.Looper.loop(Looper.java:148)
  &gt;             at android.app.ActivityThread.main(ActivityThread.java:5443)
  &gt;             at java.lang.reflect.Method.invoke(Native Method)
  &gt;             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
  &gt;             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
  &gt;      Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error
  &gt; (code 14): Could not open database
  &gt;             at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
  &gt;             at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:207)
  &gt;             at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:191)
  &gt;             at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
  &gt;             at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
  &gt;             at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
  &gt;             at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:806)
  &gt;             at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:791)
  &gt;             at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
  &gt;             at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:234)
  &gt;             at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:187)
  &gt;             at com.snitram.toriders.activities.LoginActivity.onCreate(LoginActivity.java:222)
  &gt;             at android.app.Activity.performCreate(Activity.java:6245)
  &gt;             at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1130)
  &gt;             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
  &gt;             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
  &gt;             at android.app.ActivityThread.-wrap11(ActivityThread.java)
  &gt;             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
  &gt;             at android.os.Handler.dispatchMessage(Handler.java:102)
  &gt;             at android.os.Looper.loop(Looper.java:148)
  &gt;             at android.app.ActivityThread.main(ActivityThread.java:5443)
  &gt;             at java.lang.reflect.Method.invoke(Native Method)
  &gt;             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
  &gt;             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
  </code></pre>