Android Question Error sqlchiper

jota1010

Member
Licensed User
Longtime User
When trying to encrypt my db with the system Sqlchiper me the following error:
net.sqlcipher.database.SQLiteException: file is encrypted or is not a database


B4X:
ProgressDialogShow("Iniciando base de datos, Espere...")
    If File.Exists(File.DirDefaultExternal, "encrypt.db") = False Then
  File.Copy(File.DirAssets, "encrypt.db", File.DirDefaultExternal, "encrypt.db")
  File.Copy(File.DirAssets, "sqlcipher_native.zip", File.DirDefaultExternal, "sqlcipher_native.zip")
  End If

  If FirstTime Then
  'xSQL.Initialize(File.DirDefaultExternal, "bustagenadb.db", True)
    Dim ruta As String
    ruta = File.DirDefaultExternal
    ToastMessageShow(ruta,True)
  xSql.Initialize(File.DirDefaultExternal, "encrypt.db", True, "enc", File.DirDefaultExternal)
  End If

  ProgressDialogHide


  xCursor = xSql.ExecQuery("SELECT user FROM users")

  For I = 0 To xCursor.RowCount - 1
  DoEvents
  xCursor.Position = I
  ElementoList.Add(xCursor.GetString("user"))
  Next
 

DouglasNYoung

Active Member
Licensed User
Longtime User
Jota1010,
I have had some problems along similar lines, which I haven't completely got to the bottom of. But I believe it to be incompatibilty between versions of 'sqlcipher_native.zip'.
In my case the app has been running for a long time under v1.00 of the sql_cipher library, when I upped the library to 1.10 I got this error! What I believe is happening is that the installed version of sqlcipher_native.zip (v1.00) is incompatible with the new version and throws this error. If I recompile with the new version AND change the App's package name it all works, leading me to think that it is the old sqlcipher_native which is already installed in the long running app's directory! - Changing the package name has of course ramifications for updating the current user base!

How/when did you encrypt the database?

Cheers,
Douglas
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…