title: unknown error (code 14): Could not open database when writing externally in android
body: <p>I am using the SQLiteOpenHelper to write all my queries etc. Everything is working fine when I write and read database internally but if I want to save the DB to a folder on my phone I get the following:</p>
  
  <pre><code>01-03 07:12:24.786 16097-16097/com.myApp.app E/SQLiteLog: (14) cannot open file at line 31278 of [2ef4f3a5b1]
  01-03 07:12:24.786 16097-16097/com.myApp.app E/SQLiteLog: (14) os_unix.c:31278: (2) open(/storage/emulated/0/myApp/db/app) - 
  01-03 07:12:24.787 16097-16097/com.myApp.app E/SQLiteDatabase: Failed to open database '/storage/emulated/0/myApp/db/app'.
      android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
      at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
      at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:207)
      at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:191)
      at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:463)
      at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:185)
      at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:177)
      at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:806)
      at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:791)
      at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:694)
      at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:571)
      at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:269)
      at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:223)
      at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
      at com.myApp.db.DbMain.getCountValueForMainMenu(DbMain.java:576)
      at com.myApp.app.Beginner.openApp(Beginner.java:672)
      at com.myApp.app.Beginner.checkfilepermission(Beginner.java:341)
      at com.myApp.app.Beginner.onCreate(Beginner.java:332)
      at android.app.Activity.performCreate(Activity.java:6251)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
      at android.app.ActivityThread.-wrap11(ActivityThread.java)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:148)
      at android.app.ActivityThread.main(ActivityThread.java:5417)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  </code></pre>
  
  <p><strong>DBhelper class file</strong>:</p>
  
  <pre><code> public DbMain(Context context)
      {
          // code to create database in internal storage
         //super(context, DATABASE_NAME, null, DATABASE_VERSION);
  
          //code to create database in External SD card
         super(context, Environment.getExternalStorageDirectory()
                  + File.separator + "/myApp/db/"
                  + File.separator
                  + DATABASE_NAME, null, DATABASE_VERSION);
      }
  
  @Override
      public void onCreate(SQLiteDatabase db) 
      {
          //1
          String CREATE_TABLE_MENU = "CREATE TABLE IF NOT EXISTS " + TABLE_MENU_LOCAL +"("
                  +KEY_MENUID_LOCAL + " TEXT,"
                  +KEY_MENUNAME_LOCAL + " TEXT,"
                  +KEY_ISCHILD_LOCAL + " TEXT,"
                  +KEY_CATEGORYURL_LOCAL + " TEXT,"
                  +KEY_IMAGEID_LOCAL + " TEXT,"
                  +KEY_MENUNAME_DESCRIPTION_LOCAL + " TEXT"
                  + ")";
  
          db.execSQL(CREATE_TABLE_MENU);
       }
  
      //to get totalcount
  public int getCountValueForMainMenu()
      {
          SQLiteDatabase db = this.getWritableDatabase();
          int count = 0;
          Cursor cursor = db.rawQuery("SELECT COUNT (*) FROM " + TABLE_MENU_LOCAL, null);
  
          if(null != cursor)
          {
              if(cursor.moveToFirst() &amp;&amp; 0 &lt; cursor.getCount())
              {
                  count = cursor.getInt(0);
              }
  
              cursor.close();
          }
  
          return count;
      }
  </code></pre>
  
  <p>Things are fine when call the same method etc when create DB internally.</p>
  
  <p>What could be wrong?</p>
  
  <p>Thanks!</p>