2

SQLCipher website mentions

"Init the database in onCreate() using SQLiteDatabase.loadLibs(this); //first init the db libraries with the context"

  1. 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?

  2. 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.

2 Answers 2

6
SQLiteDatabase.rawExecSQL("PRAGMA key = 'old_password';");
SQLiteDatabase.rawExecSQL("PRAGMA rekey = 'new_password';");
Sign up to request clarification or add additional context in comments.

Comments

4

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 a SQLiteDatabase object where you have provided the original password. Once you have that you can issue PRAGMA rekey = 'some new password'; using execSQL(...);. More information regarding the rekey command can be found here.

1 Comment

Are there any circumstances in which it would hurt anything to call SQLiteDatabase.loadLibs more than once?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.