Sub Activity_Create(FirstTime As Boolean)
Dim RCount As Int, N As Int, SU As StringUtils, OurList As List, X As Int, S() As String
' Load file created with Visual Designer
Activity.LoadLayout("DiaryMain")
BFBtn.Text = "Browse recent"
StatusLbl.Text = "Ready"
SrchBtn.Enabled = True
Try
'DBFilename is defined in module G (Global variables)
G.SQL1.Initialize(G.DBFileDir, G.DBFileName, True)
RCount = G.SQL1.ExecQuerySingleResult("Select count(*) from DEntries")
StatusLbl.Text = RCount & " entries in diary"
Catch
StatusLbl.Text = "No database found. Use IMPORT to create it."
End Try
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub CopyFileFromAssets (FileName As String) As String ' Note: this will overwrite without prompting
Dim TargetDir As String = File.DirRootExternal
If File.Exists(TargetDir, FileName) Then
File.Delete(TargetDir, FileName)
End If
Try
' File.DirAssets is the Files folder within our app. Is read-only - that is, we can't delete
File.Copy(File.DirAssets, FileName, TargetDir, FileName)
Return TargetDir
' Delete the source file to save space
'File.Delete(File.DirAssets, FileName)
'MsgboxAsync("Deleted file " & FileName & " from " & File.DirAssets, G.AppName)
Catch
MsgboxAsync("Error! File " & FileName & " not found in folder " & File.DirAssets, G.AppName)
End Try
End Sub
Sub SrchBtn_Click
StartActivity("Search")
End Sub
Sub ImpBtn_Click
Dim N As Int, OurLoc As String, SU As StringUtils, OurList As List, X As Int, Recd() As String
G.TFName = "data.txt" ' This name is CASE SENSITIVE so keep it simple!
'NOTE brackets after S, denoting this is a string ARRAY
' Create database if this does not already exist
StatusLbl.Text = "Importing data. Please wait..."
StatusLbl.Invalidate ' Force redraw
OurLoc = CopyFileFromAssets(G.TFName) 'Get data file from assets