Can you see what I did wrong in this code? I'm using DBUtils to populate some text boxes but I get a "Null pointer exception" on the line with the "Get". I also used a Toast to make sure that intCurrentId actually did have a value.
Here's the code I used:
Sub ListViewPeopleEventHandler_ItemClick (Position As Int, Value As Object)
' Update the details area.
'-------------------------
Dim valuesFromTheListView() As String
valuesFromTheListView = Value
intCurrentId = valuesFromTheListView(0)
Dim mapOfTableFields As Map
mapOfTableFields = DBUtils.ExecuteMap(SQL, _
"SELECT Id, FirstName, LastName FROM PeopleToVisit WHERE id = ?", _
Array As String(intCurrentId))
ToastMessageShow(intCurrentId, False)
' I get the error on this next line.
'-------------------------------------
EditTextFirstName.Text = mapOfTableFields.Get("FirstName")
EditTextFirstName.RequestFocus
EditTextFirstName.SelectAll
EditTextFirstName.Color = Colors.Cyan
EditTextLastName.Text = mapOfTableFields.Get("LastName")
EditTextLastName.RequestFocus
EditTextLastName.Color = Colors.Cyan
tableMode = "Edit"
Activity.Title = "Maintenance - Result Of Visit *** EDIT ***"
End Sub
This is the structure of the database table:
SQL.ExecNonQuery("CREATE TABLE PeopleToVisit (" & _
"Id INTEGER PRIMARY KEY, " & _
"FirstName TEXT, " & _
"LastName TEXT, " & _
"Address1 TEXT, " & _
"Address2 TEXT, " & _
"City TEXT, " & _
"State TEXT, " & _
"Zip TEXT, " & _
"PrimaryPhone TEXT, " & _
"SecondaryPhone TEXT, " & _
"Email TEXT, " & _
"LastVisitNote TEXT " & _
")")
Thanks.