opendatabase in SQLCipher taking time Android:

本小妞迷上赌 提交于 2019-12-11 13:49:38

问题


I am using SQLCipher it is working fine. I have one performance issue with this openDatabase method. My code is

SQLiteDatabase database = SQLiteDatabase.openDatabase(databasePath,
                databasePassword, null, SQLiteDatabase.OPEN_READWRITE);

This also working fine. But my problem is it takes 3 to 4 seconds time (I found time lagging in Logcat). Because of this the activity show slow response.

Note: I am calling this code from onCreate method after set setContentView(R.layout._list);

Am i doing right? Is there any other way to open database.

Is it right to call openDatabase from onCreate?


回答1:


The performance issue you are seeing is most likely due to SQLCipher key derivation. SQLCipher's performance for opening a database is deliberately slow, using PBKDF2 to perform key derivation (i.e. thousands of SHA1 operations) to defend against brute force and dictionary attacks (you can read more about this at http://sqlcipher.net/design). This activity is deferred until the first use of the database.




回答2:


I have solve my problem. Once my application is open i've open my database and save that (static method) open it from all the activities. I am not sure which is the right way or not. But it solve my problem.



来源:https://stackoverflow.com/questions/25039038/opendatabase-in-sqlcipher-taking-time-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!