dataDb.Initialize("org.sqlite.JDBC",$"jdbc:sqlite:file:${getDbFileName}?cipher=sqlcipher&legacy=4&kdf_iter=256000&key=${getKey}"$)
If dataDb.ExecQuerySingleResult("SELECT count(name) FROM sqlite_master WHERE type='table' AND name ='table1'") = 0 Then
' don't exist
Log($"Table don't exist"$)
QueryStr = _
$"CREATE TABLE IF NOT EXISTS table1 (
"number" INTEGER
);
"$
dataDb.ExecNonQuery(QueryStr)
Log("Table created")
For i = 1 To 1000
dataDb.AddNonQueryToBatch("INSERT INTO table1 VALUES (?)", Array(Rnd(0, 100000)))
Next
Dim SenderFilter As Object = dataDb.ExecNonQueryBatch("SQL")
Wait For (SenderFilter) SQL_NonQueryComplete (Success As Boolean)
Log("NonQuery: " & Success)
Log("Database file records exists")
Else
'exists
Log("Database file exists")
If dataDb.ExecQuerySingleResult("SELECT count(number) FROM table1") = 0 Then
' No records
Log("No records found!")
For i = 1 To 1000
dataDb.AddNonQueryToBatch("INSERT INTO table1 VALUES (?)", Array(Rnd(0, 100000)))
Next
Dim SenderFilter As Object = dataDb.ExecNonQueryBatch("SQL")
Wait For (SenderFilter) SQL_NonQueryComplete (Success As Boolean)
Log("NonQuery: " & Success)
Else
'records found
Log("Database file records exists")
End If
End If
QueryStr = $"dataDb.ExecQuerySingleResult("SELECT count(number) FROM table1") "$
Log(dataDb.ExecQuerySingleResult("SELECT count(number) FROM table1"))
dataDb.Close