title: Android: attempt to write a readonly database
body: <p>I have one sqlite database file and I am not able to read and write on this database file.
  I am using this code:</p>
  <pre><code>fileIsExists = new File(Environment.getExternalStorageDirectory()
              + &quot;/bbmp/bbmp2.sqlite&quot;);
      if (fileIsExists.exists()) {
  db = SQLiteDatabase.openDatabase(fileIsExists.toString(), null,
                   SQLiteDatabase.OPEN_READWRITE);        
  }
  </code></pre>
  <p>This throw following error:</p>
  <pre><code>10-01 17:09:17.343: E/Database(9216): DELETE failed setting locale
  
  10-01 17:09:17.374: E/Database(9216): Failed to setLocale() when constructing, closing the database
  
  10-01 17:09:17.374: E/Database(9216): android.database.sqlite.SQLiteException: attempt to write a readonly database
  
  10-01 17:09:17.374: E/Database(9216):   at android.database.sqlite.SQLiteDatabase.native_setLocale(Native Method)
  
  10-01 17:09:17.374: E/Database(9216):   at android.database.sqlite.SQLiteDatabase.setLocale(SQLiteDatabase.java:1987)
  
  10-01 17:09:17.374: E/Database(9216):   at android.database.sqlite.SQLiteDatabase.&lt;init&gt;(SQLiteDatabase.java:1855)
  
  10-01 17:09:17.374: E/Database(9216):   at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:820)
  
  10-01 17:09:17.374: E/Database(9216):   at com.pixel.bbmp2.Bbmp2Activity.checkDirectory(Bbmp2Activity.java:150)
  
  10-01 17:09:17.374: E/Database(9216):   at com.pixel.bbmp2.Bbmp2Activity.onCreate(Bbmp2Activity.java:115)
  
  10-01 17:09:17.374: E/Database(9216):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  
  10-01 17:09:17.374: E/Database(9216):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
  
  10-01 17:09:17.374: E/Database(9216):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
  
  10-01 17:09:17.374: E/Database(9216):   at android.app.ActivityThread.access$1500(ActivityThread.java:117)
  
  10-01 17:09:17.374: E/Database(9216):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
  
  10-01 17:09:17.374: E/Database(9216):   at android.os.Handler.dispatchMessage(Handler.java:99)
  
  10-01 17:09:17.374: E/Database(9216):   at android.os.Looper.loop(Looper.java:123)
  
  10-01 17:09:17.374: E/Database(9216):   at android.app.ActivityThread.main(ActivityThread.java:3683)
  
  10-01 17:09:17.374: E/Database(9216):   at java.lang.reflect.Method.invokeNative(Native Method)
  
  10-01 17:09:17.374: E/Database(9216):   at java.lang.reflect.Method.invoke(Method.java:507)
  
  10-01 17:09:17.374: E/Database(9216):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  
  10-01 17:09:17.374: E/Database(9216):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  
  10-01 17:09:17.374: E/Database(9216):   at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  <p>Following table are there in database file
  <img src="https://i.stack.imgur.com/uk3FU.jpg" alt="enter image description here" /></p>
  <p>What I need to do here ?????</p>