Android Question SQLcipher Read/Write Problem **In Lollipop**

Discussion in 'Android Questions' started by RichardN, Mar 21, 2015.

  1. RichardN

    RichardN Active Member Licensed User

    The code below is an extract from an app with over 2000 successful deployments. We all know an SQLite database must reside in a read/write directory... even if you are never writing to it. I now have a new user that gets an exception apparently at the SQL.Initialize statement.

    #Region  Project Attributes
    #CanInstallToExternalStorage: True
    #End Region

    Sub Process_Globals
    Dim SQL As SQLCipher
    End Sub

    Sub Activity_Create(FirstTime As Boolean)

    If FirstTime Then          'Reinitialize database every run

    File.Copy(File.DirAssets,"MyDatabase.sqlite",File.DirDefaultExternal ,"MyDatabase.sqlite")
    SQL.Initialize(File.DirDefaultExternal ,"MyDatabase.sqlite",False,z,"")     'I believe it halts here  

    End If

    'Previous coding corrected for misplacement

    End Sub
    He sent this screenshot:


    Copying the database from File.DirAssets to File.DirDefaultExternal did not throw an exception so it must follow that the destination folder is read & write. However when the SQL.Initialise statement is executed this happens.

    The platform is an HTC One M9 with Android 5.0 Lollipop. Whilst I am waiting for further details of internal/external storage config, has anyone got the faintest idea what might cause this in an apparently mature application ?
    Last edited: Mar 22, 2015
  2. Erel

    Erel Administrator Staff Member Licensed User

    Your code will initialize the SQL object multiple times. For example when the orientation changes.
    I don't know whether it is the cause of this error or not, however you should fix it.

    The first test that I would have done is to change SQLCipher to SQL and see whether you get the same error.
    Peter Simpson likes this.
  3. RichardN

    RichardN Active Member Licensed User

    Hi Erel,

    Sorry that was my typo when I copied the code across, the SQLcipher object only gets initialised once in the release version.

    I have tested the code on a different Lollipop platform with no issues. I am waiting to get hold of a subject device to have a look at the logs.
  4. RichardN

    RichardN Active Member Licensed User

    After much troubleshooting I have isolated the issue.

    SQL Cipher appears incompatible with the HTC implementation of Lollipop. I have several users who report the runtime errors above after accepting the HTC upgrade to Lollipop for their M8 & M9 platforms. No amount of clean-installation with make this previously mature app run without errors.

    I have replaced the database with an unencrypted version, commented out the SQLcipher initialisation and replaced it with the simple SQL object. In test I left the SQLcipher library attached and the present in /files. The compilation now runs without a problem. Unfortunately it seems I have no choice other than to remove SQLcipher from future projects as HTC/Lollipop user become more numerous.
    Peter Simpson likes this.
  5. Peter Simpson

    Peter Simpson Expert Licensed User

    Hmm that's interesting to know, thanks @RichardN
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice