Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim SQL As SQL
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim WebView1 As WebView
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
If FirstTime Then
SQL.Initialize(File.DirRootExternal, "test.db", True)
End If
Activity.LoadLayout("1")
'This is to show how to use the DBVersion Subs.
Dim DBVersion, CurrentDBVersion As Int
'DBVersion = DBUtils.GetDBVersion(SQL)
Log("Database Version: " & DBUtils.GetDBVersion(SQL))
If SQL.ExecQuerySingleResult("SELECT count(name) FROM sqlite_master WHERE type='table' AND name ='bpmain'") = 0 Then
'don't exist
'Creating Tables for 1st time
Dim m As Map
m.Initialize
m.Put("Id", DBUtils.DB_INTEGER)
m.Put("Date", DBUtils.DB_TEXT)
DBUtils.CreateTable(SQL, "main", m, "Id")
Log("Creating main table")
Else
'exist
Log("main table already exists")
End If
Dim Dd As DateDialog
Dim ret1 As String
Dim Cursor As Cursor
Dd.ShowCalendar = False
Dd.Year = DateTime.GetYear(DateTime.Now)
Dd.Month = DateTime.GetMonth(DateTime.Now)
Dd.DayOfMonth = DateTime.GetDayOfMonth(DateTime.Now)
Date1 = Dd.Show("Date", "Test", "Save", "Cancel","",Null)
ret1 = (Dd.Year & "-" & Dd.Month & "-" & Dd.DayOfMonth)
Log(ret1)
Cursor = SQL.ExecQuery("SELECT Id FROM main")
If Cursor.RowCount > 0 Then
For i = 0 To Cursor.RowCount - 1
Cursor.Position = i
Dim NewID As Int
NewID = Cursor.GetInt("Id")
Next
End If
NewID = NewID +1
SQL.ExecNonQuery("INSERT into main values (" & NewID & "," & ret1 & ")")
ShowTableInWebView
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub ShowTableInWebView
WebView1.Visible = True
WebView1.LoadHtml(DBUtils.ExecuteHtml(SQL, "SELECT * FROM main", Null, 0, True))
End Sub