How to implement SQLCipher when using SQLiteOpenHelper

后端 未结 2 701
遇见更好的自我
遇见更好的自我 2021-01-04 12:32

I am trying to secure some sensible data by implementing encryption in my already existing and functioning database setup in an android application.

I tried to follo

2条回答
  •  春和景丽
    2021-01-04 13:22

    In this situation how should I use SQLCipher?

    Exactly like an normal your normal sql implementation.

    Where should I define the password?

    If you are using SQLiteHelper it will create the database when you first get it like this:

    helper.getWriteableDatabase("myPassword");
    

    On the first call it will create the database with this Password. On the upcoing calls it will only work with this password.

    ( Figured that out when i went to the Source: https://github.com/sqlcipher/android-database-sqlcipher/blob/master/android-database-sqlcipher/src/main/java/net/sqlcipher/database/SQLiteOpenHelper.java, checkout the method getWriteableDatabase( String pw ) there! )

    Where should I use loadLibs(context)?

    Right before you call helper.getWriteableDatabase("myPassword"); the first time!

提交回复
热议问题