sqlcipher / android-database-sqlcipher

Android SQLite API based on SQLCipher
https://www.zetetic.net/sqlcipher/sqlcipher-for-android/
Other
2.73k stars 564 forks source link

Can not create writeable #630

Open thonguyen252 opened 10 months ago

thonguyen252 commented 10 months ago

Can open a writeable database

Couldn't open a writeable database, but a readonly instead

Couldn't open my_db.db for writing (will try read-only): net.sqlcipher.database.SQLiteDiskIOException: disk I/O error: COMMIT; at net.sqlcipher.database.SQLiteDatabase.native_execSQL(Native Method) at net.sqlcipher.database.SQLiteDatabase.execSQL(SQLiteDatabase.java:2439) at net.sqlcipher.database.SQLiteDatabase.endTransaction(SQLiteDatabase.java:834) at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:188) at net.sqlcipher.database.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:241) at net.sqlcipher.database.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:228) at net.sqlcipher.database.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:224) at org.greenrobot.greendao.database.DatabaseOpenHelper.getEncryptedWritableDb(DatabaseOpenHelper.java:134)

SQLCipher version: 4.5.0

SQLCipher for Android version: 4.5.0

Are you able to reproduce this issue within the SQLCipher for Android test suite? Not tried yet

I get this issue in the first launch - after installing the app, or after clearing data. I have to recall- mDbOpenHelper.getEncryptedWritableDb(dbPassword) for several times before be able to get a writable database. Or just in the next time I open the app, the issue is gone.

developernotes commented 10 months ago

Hi @thonguyen252,

It appears you are using the greenDAO library, are you able to reproduce this behavior outside of greenDAO? A quick test would be to try creating a connection to the same database using the SQLCipher for Android library directly. Is the database file located in the databases directory of your application, or another writable location?