title: Android - Failed to open database (SQLite)
body: <p>I am creating a database exporter library. I am taking whole database from supplied context </p>
  
  <pre><code> mContext.databaseList() //return String[] of databases
  </code></pre>
  
  <p>And then taking each database using a loop</p>
  
  <pre><code>  File databasePath = mContext.getDatabasePath(databaseName);
          SQLiteDatabase db = SQLiteDatabase.openDatabase(databasePath.getAbsolutePath(), null, 0);
  </code></pre>
  
  <p>for testing purpose, I used a real-time project, then I noticed a database that i didn't create called </p>
  
  <p><code>SLM_B.db-journal.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back</code></p>
  
  <p>When I try to open this database I got this issue.</p>
  
  <pre><code>Failed to open database '/data/user/0/com.samsung.lighting/databases/SLM_B.db-journal.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back.back'.
                    android.database.sqlite.SQLiteDatabaseCorruptException: file is encrypted or is not a database (code 26): , while compiling: PRAGMA journal_mode
                    #################################################################
                    Error Code : 26 (SQLITE_NOTADB)
                    Caused By : File opened that is not a database file or encrypted.
                      (file is encrypted or is not a database (code 26): , while compiling: PRAGMA journal_mode)
                    #################################################################
                        at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
                        at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1009)
                        at android.database.sqlite.SQLiteConnection.executeForString(SQLiteConnection.java:713)
                        at android.database.sqlite.SQLiteConnection.setJournalMode(SQLiteConnection.java:387)
                        at android.database.sqlite.SQLiteConnection.setWalModeFromConfiguration(SQLiteConnection.java:361)
                        at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:250)
                        at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:201)
                        at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:514)
                        at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:206)
                        at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:178)
                        at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:934)
                        at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:898)
                        at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:708)
                        at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:683)
                        at com.godwin.databasedebugger.DatabaseExporter.exportDB(DatabaseExporter.java:41)
                        at com.godwin.databasedebugger.TableListFragment.exportDatabase(TableListFragment.java:55)
                        at com.godwin.databasedebugger.TableListFragment.onViewCreated(TableListFragment.java:50)
                        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1314)
                        at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
                        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
                        at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758)
                        at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2363)
                        at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2149)
                        at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2103)
                        at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2013)
                        at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:388)
                        at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:607)
                        at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
                        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1266)
                        at android.app.Activity.performStart(Activity.java:6943)
                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3277)
                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3416)
                        at android.app.ActivityThread.access$1100(ActivityThread.java:230)
                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1822)
                        at android.os.Handler.dispatchMessage(Handler.java:102)
                        at android.os.Looper.loop(Looper.java:148)
                        at android.app.ActivityThread.main(ActivityThread.java:7409)
                        at java.lang.reflect.Method.invoke(Native Method)
                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
  08-27 19:24:32.801 E: file is encrypted or is not a database (code 26): , while compiling: PRAGMA journal_mode
                    #################################################################
                    Error Code : 26 (SQLITE_NOTADB)
                    Caused By : File opened that is not a database file or encrypted.
                      (file is encrypted or is not a database (code 26): , while compiling: PRAGMA journal_mode)
                    #################################################################
                    android.database.sqlite.SQLiteDatabaseCorruptException: file is encrypted or is not a database (code 26): , while compiling: PRAGMA journal_mode
                    #################################################################
                    Error Code : 26 (SQLITE_NOTADB)
                    Caused By : File opened that is not a database file or encrypted.
                      (file is encrypted or is not a database (code 26): , while compiling: PRAGMA journal_mode)
                    #################################################################
                        at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
                        at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1009)
                        at android.database.sqlite.SQLiteConnection.executeForString(SQLiteConnection.java:713)
                        at android.database.sqlite.SQLiteConnection.setJournalMode(SQLiteConnection.java:387)
                        at android.database.sqlite.SQLiteConnection.setWalModeFromConfiguration(SQLiteConnection.java:361)
                        at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:250)
                        at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:201)
                        at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:514)
                        at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:206)
                        at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:178)
                        at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:934)
                        at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:898)
                        at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:708)
                        at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:683)
                        at com.godwin.databasedebugger.DatabaseExporter.exportDB(DatabaseExporter.java:41)
                        at com.godwin.databasedebugger.TableListFragment.exportDatabase(TableListFragment.java:55)
                        at com.godwin.databasedebugger.TableListFragment.onViewCreated(TableListFragment.java:50)
                        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1314)
                        at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1528)
                        at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1595)
                        at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758)
                        at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2363)
                        at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2149)
                        at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2103)
                        at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2013)
                        at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:388)
                        at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:607)
                        at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
                        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1266)
                        at android.app.Activity.performStart(Activity.java:6943)
                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3277)
                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3416)
                        at android.app.ActivityThread.access$1100(ActivityThread.java:230)
                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1822)
                        at android.os.Handler.dispatchMessage(Handler.java:102)
                        at android.os.Looper.loop(Looper.java:148)
                        at android.app.ActivityThread.main(ActivityThread.java:7409)
                        at java.lang.reflect.Method.invoke(Native Method)
                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                      at com.andr
  </code></pre>
  
  <blockquote>
    <p>And my questions are</p>
    
    <ol>
    <li>why this database?</li>
    <li>Is there anything like this for another type of application?</li>
    <li>How to avoid this? (than String comparison)</li>
    <li>How to encrypt or decrypt own database?</li>
    </ol>
  </blockquote>