0

I am facing one problem with sqlcipher since last month.

In my project I use existing database which is stored in raw folder of resources folder.

I open the database by using SQLiteDatabase.openOrCreateDatabase() method. It is working fine in all devices before version 5.0. But It shows me error on Android 5.x and above version with log as follows: I also searched on internet.I found same issues found in link but there is no solution of it. link as: https://github.com/sqlcipher/android-database-sqlcipher/issues/161

Error log as follows:

DELETE failed setting locale 08-13 09:44:58.388: E/Database(6507): Failed to setLocale() when constructing, closing the database 08-13 09:44:58.388: E/Database(6507): net.sqlcipher.database.SQLiteException: attempt to write a readonly database 08-13 09:44:58.388: E/Database(6507): at net.sqlcipher.database.SQLiteDatabase.native_setLocale(Native Method) 08-13 09:44:58.388: E/Database(6507): at net.sqlcipher.database.SQLiteDatabase.setLocale(SQLiteDatabase.java:2098)

Abhinav Singh Maurya
  • 3,313
  • 8
  • 33
  • 51
  • tried `SQLiteDatabase.NO_LOCALIZED_COLLATORS` flag? – pskink Aug 14 '15 at 08:54
  • I have error on line : database = SQLiteDatabase.openOrCreateDatabase(DATABASE_ABSOLUTE_NAME, "password", null,hook); - Here no paramater to add SQLiteDatabase.NO_LOCALIZED_COLLATORS flag – Ashik Lanjewar Aug 14 '15 at 09:31
  • did you try that flag (used with `openDatabase`)? – pskink Aug 14 '15 at 09:34
  • yes...then also it gives me same error..Actually its working fine with other devices but not in android version 5.0. – Ashik Lanjewar Aug 14 '15 at 11:56
  • so use SQLiteDatabase.OPEN_READWRITE too – pskink Aug 14 '15 at 12:05
  • I used both flags parameter like SQLiteDatabase.OPEN_READWRITE | SQLiteDatabase.NO_LOCALIZED_COLLATORS. Now I got the issue, In Android 5.0 and above the external storage as internal memory get retrive.The database get created but not get open and shows "attempt to write a readonly database" error. When I move database into data folder by using getFiles() method instead of getExternalFilesDir() method. It is working fine. But I want to store data in external storage so that phone memory data not get use more.Please help me what to do. I have to open database from internal memory in android 5.0 – Ashik Lanjewar Aug 14 '15 at 12:56
  • how come you get "attempt to write a readonly database" if you use OPEN_READWRITE flag? post the code of what you are doing – pskink Aug 14 '15 at 12:58

0 Answers0