rivate Sub CreateDBTables
AppLog("CreateDBTables :: Start")
If SQLite.ExecQuerySingleResult( _
"SELECT count(name) FROM sqlite_master WHERE type='table' AND name='Tasks'") = 0 Then
SQLite.ExecNonQuery("PRAGMA journal_mode = wal") 'best mode for multithreaded apps.
' Create the table Tasks if it doesn't already exist
Dim columns As Map
columns.Initialize
columns.Put("ID", DBUtils.DB_INTEGER)
columns.Put("Task", DBUtils.DB_TEXT)
columns.Put("Description", DBUtils.DB_TEXT)
columns.Put("Date", DBUtils.DB_TEXT)
AppLog("Table Tasks created.")
DBUtils.CreateTable(SQLite, "Tasks", columns, "ID")
' fill the table with dummy data
Dim ListOfMaps As List
ListOfMaps.Initialize
Dim id As Int
For i = 1 To 5
Dim m As Map
m.Initialize
id = Rnd(id + 1, id + 10000)
m.Put("Task", "Task " & id)
m.Put("Description", "Description" & i)
m.Put("Date", DateTime.Date(DateTime.Now))
ListOfMaps.Add(m)
Next
DBUtils.InsertMaps(SQLite, "Tasks", ListOfMaps)
AppLog("Table Tasks test data inserted.")
End If
AppLog("CreateDBTables :: End")
End Sub