hmmm this is with yours added but i get an error trying to run it
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim SQL1 As SQL
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Begin - Change for Database>>>>>>>>>>>>>>>>>>>>>>>>>>
Dim DBFileName As String : DBFileName = "Contacts.db"
Dim DBTableName As String : DBTableName = "People"
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<End - Change for Database>>>>>>>>>>>>>>>>>>>>>>>>>>
' Dim DBFileDir As String : DBFileDir = File.DirInternal
Dim DBFileDir As String : DBFileDir = File.DirDefaultExternal
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 ListView1 As ListView
Dim sqltxt As String
Dim cur As Cursor
Dim Label1 As Label
Dim btnAdd As Button
Dim txtName As EditText
Dim txtSurname As EditText
Dim txtTown As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
Dim TargetDir As String
If File.ExternalWritable Then TargetDir = File.DirDefaultExternal Else TargetDir = File.DirInternal
If File.Exists(TargetDir, DBFileName) = False Then
File.Copy(File.DirAssets, DBFileName, TargetDir, DBFileName)
End If
End If
SQL1.Initialize(DBFileDir, DBFileName, True)
Activity.LoadLayout("listviewbb")
sqltxt = "SELECT * FROM People ORDER by FirstName"
ListViewInit
ListViewFill
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub ListViewInit
ListView1.SingleLineLayout.ItemHeight = 40dip
ListView1.SingleLineLayout.Label.Left = 0
ListView1.SingleLineLayout.Label.Height = 40dip
ListView1.SingleLineLayout.Label.Gravity = Gravity.CENTER_VERTICAL
ListView1.SingleLineLayout.Label.Color = Colors.White
ListView1.SingleLineLayout.Label.TextSize = 15
ListView1.SingleLineLayout.Label.TextColor = Colors.Black
ListView1.FastScrollEnabled = True
End Sub
Sub ListViewFill
ListView1.Clear
cur = SQL1.ExecQuery(sqltxt)
For i = 0 To cur.RowCount - 1
cur.Position = i
ListView1.AddSingleLine(cur.GetString("FirstName") & ", " & (cur.GetString("Surname")))
Next
End Sub
Sub ListView1_ItemClick (Position As Int, Value As Object)
Dim townlabel As String
Label1.Text = Value
cur = SQL1.ExecQuery(sqltxt)
For i = 0 To cur.RowCount - 1
cur.Position = i
If cur.GetString("FirstName") & ", " & (cur.GetString("Surname")) = Value Then
townlabel = (cur.GetString("Town"))
Label1.Text = townlabel
End If
Next
End Sub
Sub ListView1_ItemLongClick (Position As Int, Value As Object)
Dim Name() As String
Name=Regex.Split(",",Value) 'Name(0) is first name, Name(1) is Surname in that order
SQL1.ExecNonQuery("DELETE FROM People WHERE FirstName= ? AND Surname= ?", Array As String(Name(0),Name(1)))
End Sub
Sub btnAdd_Click
SQL1.ExecNonQuery("INSERT INTO People VALUES('" & txtSurname.Text & "','" & txtName.text & "','" & txtTown.Text & "')")
ListViewFill
End Sub