I am investigating using MAP to store my data, if it runs like a hashtable it will be great. However I have found only a few lines of code and not one actual layout on how to use it.
Can someone please help?
Here is a database call that happily loads the listview, I want the data to also pass to the map so I can call it later. The DB call loads the listivew happily, just doesn't load the MAP
At the other end I want to get out the value when the key matches. i tried a number of ways but of course as it seems the data isn't going in, it certainly won't look good coming out. using a hash table I don't remember having to iterate across the keys.
Can someone please help?
Here is a database call that happily loads the listview, I want the data to also pass to the map so I can call it later. The DB call loads the listivew happily, just doesn't load the MAP
B4X:
Sub DBload ' load the alternative names db
'need to clear the list
lvdb.Clear
cursor1 = SQL1.ExecQuery("SELECT * FROM name")
For i = 0 To cursor1.RowCount - 1
cursor1.Position = i
lvdb.AddSingleLine(cursor1.GetString("ID")& " : " &cursor1.GetString("name")& " = " &cursor1.GetString("altname"))
'this works and loads up the data into the listview
lvdb.SingleLineLayout.Label.TextSize = 15
lvdb.SingleLineLayout.ItemHeight = 40
lvdb.SingleLineLayout.label.TextColor = Colors.Black
lvdb.ScrollingBackgroundColor =Colors.Transparent
'map here not working, it returns just the Key: mapname , Value: mapaltname
'I suspect its just overwriting the same data field yet its is looping with the main loop the cursor1.getString("name") should work as it does above.
Dim mapname, mapaltname As String
mapname=cursor1.getString("name")
mapaltname=cursor1.getString("altname")
allmapnames.Put("mapname", "mapaltname")
Log("mapname " & mapname)
Log("mapaltname " & mapaltname)
Next
End Sub
At the other end I want to get out the value when the key matches. i tried a number of ways but of course as it seems the data isn't going in, it certainly won't look good coming out. using a hash table I don't remember having to iterate across the keys.
B4X:
If From = PhoneNum Then
Log(Contact.DisplayName)
'add custom names to here with MAP
For i = 0 To allmapnames.Size - 1
If allmapnames.ContainsKey(Contact.DisplayName) Then
'If Contact.DisplayName = allmapnames.ContainsKey(i) Then
Contact.DisplayName = allmapnames.GetValueAt(Contact.DisplayName)
End If
Last edited: