Android Question Determine SQL-Cipher-database encryption

BlueVision

Member
Licensed User
Longtime User
Imagine, you have an application using an SQLlite-Database. The enduser is able to decide if he wants this database encrypted or not by changing some setup-parameters inside the application. The encryption is done using SQLCipher. The code inside the application is able to convert the database by moving the data from an unencrypted database to a new encrypted and back.
Imagine further, that there is kind of backup-stuff done inside this app, the created backup-file may be an old one when restored, it may be encrypted or not. So the application has to know if this backup is encrypted or not when it comes to the point of restoring the file.
Is there a simple way to give the database a poll to know how to do organize the import? If you try to open an SQLCipher-encoded Database with the regular SQLlite-Instuctions, the application may crash and vice versa.
So far I used the filename to determine if the database is an encrypted one or not, to decide how to import. Maybe there is a better way? Any ideas? Anyone got the same problem in the past?

Cheers from Berlin, Andi
 

BlueVision

Member
Licensed User
Longtime User
Thanks for your fast response Erel. Sounds good and I will give it a try. This means that I have to give my whole databasecoding a rework now... :(
Best way would be calling a small subroutine always before accessing the database to detect if its encrypted or not.
 
Upvote 0
Top