I am transitioning my app to use SQLCipher through the 'appcelerator.encrypteddatabase' module.
Existing devices will have an unencrypted SQLite database which the app will need to do a sqlcipher_export() on.
See documentation here [
https://www.zetetic.net/sqlcipher/sqlcipher-api/#sqlcipher_export](
https://www.zetetic.net/sqlcipher/sqlcipher-api/#sqlcipher_export)
I am now able to get the ATTACH command to work. But I cannot use the database for anything afterwards. It is as though the encrypteddatabase module is holding on to a reference to the DB.
See my attached app.js example.
1.You can click the first button as many times as you like to create and add data to an unencrypted DB.
2. This will create an encrypted DB, attach it, export it.
3. This will now cause an exception
4. Restart the app
5. Button 3 now works perfectly.
I have tried everything I can think of to get around this, and there's nothing in the SQLCipher documentation that I appear to be doing wrong.
Thanks for your help!. [^app.js]
Hello [~mark.henderson@snagr.co.uk], Thanks for reporting this . Are you using 7.5.2SDK for build? Can you please test on 8.0.0.GA? And also share the console logs here.
Technically I'm using 7.5.2GA for production. But for this test I've also tried with 8.0.0GA. I'm pretty sure this is a bug with EncryptedDatabase module, as I've re-written this code 5 different ways today and tried almost everything. Whatever is locking it is removed when you re-launch the app. But after the attach / export / detach the database is completely locked. I also tried the second method of exporting a plaintext database into a new encrypted database. But this module gives an error message 'incorrect number of arguments'. I can also see that this module is using SQLCipher v3 not v4, as I need to set DB Browser for SQLite to this mode in order to decrypt and view the database. So I think it should be updated internally if there is a bug. Here are the console logs:
Thanks!
Hi Shak, do let me know if there's any other information you require. I'm happy to help with any testing etc.. Unfortunately as the module is closed source I can't do too much.
I seem to have got this working finally.. It seems for iOS by checking the cipher upgrade and also making sure that after initialising appcelerator.encrypteddatabase I only use that to open database connections, not Ti.Database anymore. Here's the change to the code in case it helps anyone else in the future: