Android Question How can you decrypt a database using SQLCipher?

Silentsea

Member
Licensed User
Longtime User
I am the one encrypting the database and I also want to be able to decrypt it (mainly because SqliteBrowser doesn't seem able to deal with (Android)-encrypted DB's).

I tried the following:

B4X:
Dim SQL As SQLCipher

SQL.Initialize(cAppSettings.Dir_Data, "sdata.db", True, cAppSettings.DBPW, "")
SQL.ExecQuery ("PRAGMA cipher_migrate")
'This works fine for accessing the encrypted DB.

'<Test>
SQL.ExecQuery("PRAGMA key = " & cAppSettings.DBPW)
Dim plaintextDbPath As String = cAppSettings.Dir_Data & "/plaintext.db"
Dim nextSQLStatement As String = "ATTACH DATABASE '" & plaintextDbPath & "' AS plaintext KEY ''"
' nextSQLStatement: [ATTACH DATABASE '/storage/emulated/0/<AppName>/Data/plaintext.db' AS plaintext KEY '']
SQL.ExecQuery(nextSQLStatement)
SQL.ExecQuery("SELECT sqlcipher_export('plaintext')")
SQL.ExecQuery("DETACH DATABASE plaintext")
'</Test>

(Idea for this from here: https://stackoverflow.com/questions...ypted-sqlcipher-database-file-on-command-line)
This does not throw any errors but I also do not get a plaintext.db next to my encrypted sdata.db. :(
 
Top