#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#End Region
'https://github.com/Willena/sqlite-jdbc-crypt/releases
'https://github.com/Willena/sqlite-jdbc-crypt/releases/tag/3.46.0.0
'Working
#AdditionalJar: sqlite-jdbc-3.30.0
#AdditionalJar: sqlite-jdbc-3.31.1
#AdditionalJar: sqlite-jdbc-3.35.5.1
'Using the latest Version, you need to Add the slf4j API, otherwise you will get Class not found
#AdditionalJar: slf4j-api-2.0.17
#AdditionalJar: slf4j-nop-1.7.36
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Private Button1 As B4XView
Dim dbName As String = "test.db"
Dim password As String = "1234"
Dim sql As SQL
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
If File.Exists(File.DirApp,dbName) = False Then
File.Copy(File.DirAssets,dbName,File.DirApp,dbName)
Log("file copied")
End If
Sleep(0)
If sql.IsInitialized = False Then
dim d as string = file.combine(file.dirApp,dbName)
'===========Database and App in one location======================
sql.Initialize("org.sqlite.JDBC",$"jdbc:sqlite:file:${d}?cipher=sqlcipher&legacy=4&kdf_iter=256000&key=${Password}"$)
'===========You can also specify Path to the Database============================
'sql.Initialize("org.sqlite.JDBC",$"jdbc:sqlite:file:${d}?cipher=sqlcipher&legacy=4&key=${Password}&kdf_iter=256000"$)
Log("DB Started")
End If
End Sub
Sub Button1_Click
If sql.IsInitialized Then
Dim ver As String = sql.ExecQuerySingleResult("SELECT ID from Test")
Log(ver)
End If
End Sub