Android Question SQLITE on Marshmallow

Rusty

Well-Known Member
Licensed User
Longtime User
Is there a new SQLite version that is able to run on Marshmallow?
My exact version of code that runs on ICS to KitKat is blowing up in the first SQLite IO.

I'm using:
SQL version 1.30
SQLCipher version 1.20
icudt46l.zip
 

Rusty

Well-Known Member
Licensed User
Longtime User
Thanks,
I have attempted to follow those instructions but it is still failing.
B4X:
Try
                    Main.SQLSurvey.initialize(Main.SDCard.data, Main.DBSurvey, False, Main.SqliteKey, File.DirAssets ) 'use the encrypted database
                    Dim C As Cursor = Main.SQLSurvey.ExecQuery ("PRAGMA cipher_migrate")  'convert 1.2 to 1.3
                Catch
                    Main.SQLSurvey.initialize(Main.SDCard.data, Main.DBSurvey, False, "", File.DirAssets )  'in case it's not encrypted
                End Try
                Try
                    Dim C As Cursor = Main.SQLSurvey.ExecQuery("PRAGMA journal_mode=OFF") 'kill any journalling
                    Retcd = True
                Catch
                    Log("Couldn't set Pragma " & Main.SQLSurvey)
                End Try
                Try
                    C.Close   
                Catch
                    Log(LastException)
                End Try
(lots of try catches)

JAR versions:
SQL v 1.30
SQLCipher v1.30

Results: net.sqlcipher.database.SQLiteException: error code 14: Could not open database
Any insight will be appreciated.
Thanks
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
NEW STATUS: I failed to put #DebuggerForceStandardAssets: True in the attributes, after adding this, it is now running the Klaus SimpleSQLite1, converted.
My main app, however is still failing...

I can compile and successfully run Klaus' SimpleSQLite1 example to Cipher here
When I convert it to SQLCipher, it crashes.
B4X:
        If File.Exists(File.DirInternal, "persons.db") = False Then
            'if not, initialize it
            'Main.SQLSurvey.initialize(Main.SDCard.data, Main.DBSurvey, False, Main.SqliteKey, File.DirAssets )
            SQL1.Initialize(File.DirInternal, "persons.db", True, "abc", File.DirAssets)
            'and create it
            CreateDataBase
        Else
            'if yes, initialize it
            SQL1.Initialize(File.DirInternal, "persons.db", False, "abc", File.DirAssets)
        End If
it says :
java.lang.RuntimeException: java.io.FileNotFoundException: icudt46l.zip


The file IS there though.
 
Last edited:
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
...OK, I got it working in my app and the databases are all migrated.
Last question, once the databases are migrated, how can we know that the database has been migrated so we can discontinue "migrating" each time?
thanks,
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
Hi Erel,
Thanks for the advice.
I found a user field available that might work without using a table (version).
Will the following code be as efficient?

B4X:
'checks database version and migrates if necessary
'SQL1 must already be initialized
Sub MigrateSQLite(SQL1 As SQLCipher, CurVer As Int)
    Dim thisVer As Int = SQL1.ExecQuerySingleResult ("PRAGMA user_version")    'get the version
    Dim C As Cursor
    If thisVer < CurVer Then
        C = SQL1.ExecQuery ("PRAGMA cipher_migrate")                     'migrate the database to the new version
        SQL1.ExecNonQuery("PRAGMA user_version = " & CurVer)        'set the new version
    End If
    Try
        C = SQL1.ExecQuery("PRAGMA journal_mode=OFF")
    Catch
        Log("Couldn't set Pragma " & SQL1)
    End Try
    C.Close
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…