SQLCipher website mentions
“Init the database in onCreate() using SQLiteDatabase.loadLibs(this); //first init the db libraries with the context”
-
I am calling this loadlibs only once in my first activity (seems to be working). I want to make sure I do not need to call this function for every activity that might access the database. Is this correct?
-
How do I change the database password? I tried rekey but that does not work. It still takes the old password.
Any help would be appreciated.
Thank you.
Yes, that is correct – you only need to call
SQLiteDatabase.loadLibs(...);once as that is responsible for loading the various native libraries SQLCipher for Android uses at runtime into the process. To change the password, you must first have a reference to aSQLiteDatabaseobject where you have provided the original password. Once you have that you can issuePRAGMA rekey = 'some new password';usingexecSQL(...);. More information regarding the rekey command can be found here.