Encrypt onUpgrade

Can I encrypt the unencrypted db during the onUpgrade call in my dbhelper?

Also how do I make sure the app encrypts only once? This is to avoid users from replacing unencrypted db multiple times.

Hello @bluefish

If you have a plain text SQLite database, you can encrypt your database, you will want to look into the sqlcipher_export(…) convenience function, specifically example #1. If you are able to open the database without a password, you would need to encrypt it, otherwise, you would need a password to access the database content.

I am interested specifically in encrypting the DB on onUpgrade(db) call. Is that possible?

Hi @bluefish

Yes, you can use the onUpgrade(…) callback function as a point to encrypt the database.