Android的SQLcipher PRAGMA问题 [英] Android SQLcipher PRAGMA problems
问题描述
我有一个一些问题SQLcipher分贝为Android
该文档是不是太描述性的,所以我不能弄明白。
我想修改迭代的默认数量上sqlcipher为Android,
我编辑与sqlcipher演示应用程序提供的notecipher应用程序,并希望增加kdf_iter到5000,即
通过在数据库帮助我只是文件后,进入编译值覆盖getWritableDatabase()方法是用密码打开。
我可以打开并初始化数据库,但如果我做了database.close()调用,我不能重新打开数据库。
每当我结束对下一个打开的数据库()调用我得到一个:
I /数据库(807):sqlite的返回:错误code = 26,味精=文件加密或不是一个数据库
E /数据库(807):CREATE TABLE android_metadata失败
E /数据库(807):未能setlocale()的施工时,关闭数据库
E /数据库(807):info.guardianproject.database.sqlcipher.SQLiteException:文件被加密或不是数据库
@Stephen答案只有部分正确,因为根据的文档:
PRAGMA kdf_iter必须名为在 PRAGMA键和第一实际的数据库操作之前,否则将没有任何效果。
块引用>所以行:结果
database.rawExecSQL(PRAGMA kdf_iter = 5000);
块引用>必须在postKey()方法不是在pre键()插入,和。
结果
这为我工作。Hey guys I am having a some problems with SQLcipher db for android The documentation is not too descriptive so I could not figure it out.
I am trying to modify the default number of iterations on sqlcipher for android, I am editing the notecipher app provided as demo app with sqlcipher, and want to increase the kdf_iter to i.e. 5000
By overriding the getWritableDatabase() method in the database helper i enter the pragma value just after the file is open with the password.
I can open and initialize the database, but I cannot re-open the db if I do a database.close() call.
whenever I close the database on the next open() call I get a :
I/Database(807): sqlite returned: error code = 26, msg = file is encrypted or is not a database E/Database(807): CREATE TABLE android_metadata failed E/Database(807): Failed to setLocale() when constructing, closing the database E/Database(807): info.guardianproject.database.sqlcipher.SQLiteException: file is encrypted or is not a database
解决方案@Stephen answer is only partially correct, because according to the documentation:
PRAGMA kdf_iter must be called after PRAGMA key and before the first actual database operation or it will have no effect.
So the line:
database.rawExecSQL("PRAGMA kdf_iter = 5000");
Must be inserted in the postKey() method, and NOT in preKey().
This worked for me.这篇关于Android的SQLcipher PRAGMA问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!