我有一个已投入生产多年的应用。它使用内部使用标准 SQLite 数据库的 DBFlow。该应用的最新版本集成了 SqlCipher 4.4.3 库。
我按照 this 方法加密数据库,然后如果我将其安装为新应用程序,它就可以工作,但是当我将此应用程序安装在没有加密数据库的旧应用程序之上时,它就失败了除了这个例外。
net.sqlcipher.database.SQLiteException: file is not a database:,while compiling: select count(*) from sqlite_master;
我试图从表中读取一些数据:
UserTable.findByUuid(uuid);
我试着像这样打开数据库:
SQLiteDatabase.loadLibs(this);
File dbFile = getDatabasePath("myDBName.db");
SQLiteDatabase.openOrCreateDatabase(dbFile,"passphrase",null);
用户表:
public class UserTable {
public static User findByUuid(String uuid) {
return SQLite.select().from(User.class).where(User_Table.uuid.eq(uuid)).querySingle();
}
}
用户模型:
@Table(database = DatabaseManager.class)
public class User extends BaseModel {
@Column
String uuid;
// all other fields and set and get methods to go here
}
问题: 如何为现有应用打开加密数据库以在 DB Flow 中执行读/写操作?