我可以找到很多旧版本的 SQLCipher 与 android 的集成示例,它也可以工作。但我需要集成最新版本的 SQLCipher,如 v4.5.4,因为它提到它有更多的性能优化。谁能帮我解决这个问题?
我尝试了 SQLCipher 最新文档中给出的步骤,但我无法遵循该步骤,因为它不清楚并且需要我不知道如何获取的数据库文件路径。
我知道了
System.loadLibrary("sqlcipher")
val factory = SupportOpenHelperFactory(encryptionKey)
// if the INSTANCE is not null, then return it,
// if it is, then create the database
return INSTANCE ?: synchronized(this) {
val instance = Room.databaseBuilder(
context.applicationContext,
MYDatabase::class.java,
DATABASE_NAME
)
.openHelperFactory(factory)
.addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4, MIGRATION_4_5)
.build()
INSTANCE = instance
// return instance
instance
}
这里应该在任何数据库操作发生之前调用 System.loadLibrary("sqlcipher")