sqlcipher / sqlcipher-android

SQLCipher for Android provides an interface to SQLCipher databases on the Android platform.
Other
85 stars 17 forks source link

updating to sqlcipher-android from android-database-sqlcipher file is not a database (code 26) #34

Open xuhongchang opened 1 month ago

xuhongchang commented 1 month ago

from android-database-sqlcipher 4.5.4 to sqlcipher-android4.5.6 receive some error If it is a new installation, it is not a problem, only the overlay installation is a problem here is log: Failed to open database android.database.sqlite.SQLiteException: file is not a database (code 26): , while compiling: SELECT COUNT(*) FROM sqlite_schema; at net.zetetic.database.sqlcipher.SQLiteConnection.nativePrepareStatement(Native Method) at net.zetetic.database.sqlcipher.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:973) at net.zetetic.database.sqlcipher.SQLiteConnection.executeForLong(SQLiteConnection.java:628) at net.zetetic.database.sqlcipher.SQLiteConnection.open(SQLiteConnection.java:240) at net.zetetic.database.sqlcipher.SQLiteConnection.open(SQLiteConnection.java:202) at net.zetetic.database.sqlcipher.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:475) at net.zetetic.database.sqlcipher.SQLiteConnectionPool.open(SQLiteConnectionPool.java:189) at net.zetetic.database.sqlcipher.SQLiteConnectionPool.open(SQLiteConnectionPool.java:181) at net.zetetic.database.sqlcipher.SQLiteDatabase.openInner(SQLiteDatabase.java:1028) at net.zetetic.database.sqlcipher.SQLiteDatabase.open(SQLiteDatabase.java:1013) at net.zetetic.database.sqlcipher.SQLiteDatabase.openDatabase(SQLiteDatabase.java:840) at net.zetetic.database.sqlcipher.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:359) at net.zetetic.database.sqlcipher.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:278)

xuhongchang commented 1 month ago

sqlcipher-android4.5.6 version use code : public SQLiteOpenHelper(Context context, String name, byte[] password, CursorFactory factory, int version, int minimumSupportedVersion, DatabaseErrorHandler errorHandler, SQLiteDatabaseHook databaseHook, boolean enableWriteAheadLogging)

android-database-sqlcipher 4.5.4 version use code: public SQLiteOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version, SQLiteDatabaseHook hook) { this(context, name, factory, version, hook, new DefaultDatabaseErrorHandler()); }

public synchronized SQLiteDatabase getWritableDatabase(String password) {
    return this.getWritableDatabase(password == null ? null : password.toCharArray());
}
developernotes commented 1 month ago

Hi @xuhongchang,

What happens when you retrieve your existing database file off the Android device and attempt to access it within DB Browser for SQLite ^1?

xuhongchang commented 1 month ago

how to upgrade android-database-sqlcipher 4.5.4 to sqlcipher-android4.5.6 ? Android system. I referenced the migration documentation:https://www.zetetic.net/sqlcipher/sqlcipher-for-android-migration/

If it is a new installation, it is not a problem, only the overlay installation is a problem

here is log: Failed to open database android.database.sqlite.SQLiteException: file is not a database (code 26): , while compiling: SELECT COUNT(*) FROM sqlite_schema; at net.zetetic.database.sqlcipher.SQLiteConnection.nativePrepareStatement(Native Method) at net.zetetic.database.sqlcipher.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:973) at net.zetetic.database.sqlcipher.SQLiteConnection.executeForLong(SQLiteConnection.java:628) at net.zetetic.database.sqlcipher.SQLiteConnection.open(SQLiteConnection.java:240) at net.zetetic.database.sqlcipher.SQLiteConnection.open(SQLiteConnection.java:202) at net.zetetic.database.sqlcipher.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:475) at net.zetetic.database.sqlcipher.SQLiteConnectionPool.open(SQLiteConnectionPool.java:189) at net.zetetic.database.sqlcipher.SQLiteConnectionPool.open(SQLiteConnectionPool.java:181) at net.zetetic.database.sqlcipher.SQLiteDatabase.openInner(SQLiteDatabase.java:1028) at net.zetetic.database.sqlcipher.SQLiteDatabase.open(SQLiteDatabase.java:1013) at net.zetetic.database.sqlcipher.SQLiteDatabase.openDatabase(SQLiteDatabase.java:840) at net.zetetic.database.sqlcipher.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:359) at net.zetetic.database.sqlcipher.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:278)

developernotes commented 1 month ago

Hi @xuhongchang,

What happens when you pull the existing database off the Android device and access it with the password using DB Browser for SQLite ^1?