I need to read these settings in from a SQLite table that I created... one, I can't figure out what I am doing wrong, or what is the proper way to read in all the values in a table... two, this is kinda practice for later on in my program. If I can figure th's out, I can really get moving.
I have tried tons of combinations/variations, maps, lists, etc. Can someone please show me the correct way to read this table into map variables.
I have heavily commented the code for clarification and log results.
THANK YOU, and sorry in advance... not a "COMPLETE NOOB", even though I feel like it at this point.
I have tried tons of combinations/variations, maps, lists, etc. Can someone please show me the correct way to read this table into map variables.
I have heavily commented the code for clarification and log results.
THANK YOU, and sorry in advance... not a "COMPLETE NOOB", even though I feel like it at this point.
B4X:
Sub Read_tblSettings
'This is the values I used to fill the SQL table with earlier...
'listSettingName.AddAll(Array As String("varDebugState", "Test"))
'listSettingValue.AddAll(Array As String("1", "Test Text"))
'
'SQL1 Table tblSettings overview:
'Cols: SettingName | Value
'Row 1: varDebugState | 1
'Row 1: Test | Test Text
'Test a webview - This works, so I know the table is filled correctly...
' webviewSettings.Visible = True
' webviewSettings.LoadHtml(DBUtils.ExecuteHtml(SQL1, _
' "SELECT SettingName, Value FROM tblSettings", _
' Null, 0, True))
Dim listSettingName As List
Dim listSettingValue As List
listSettingName.Initialize
listSettingValue.Initialize
'This reads out correctly
listSettingName.AddAll(Array As String(DBUtils.ExecuteMemoryTable(SQL1, "SELECT SettingName FROM tblSettings", Null, 0)))
listSettingValue.AddAll(Array As String(DBUtils.ExecuteMemoryTable(SQL1, "SELECT Value FROM tblSettings", Null, 0)))
Log("Read_tblSettings - listSettingName: " & CRLF & listSettingName)
'Log shows...
'Read_tblSettings - listSettingName:
'(ArrayList) [(ArrayList) [[Ljava.lang.String;@40b352d8, [Ljava.lang.String;@40b35520]]
Log("Read_tblSettings - listSettingValue: " & CRLF & listSettingValue)
'Log shows...
'Read_tblSettings - listSettingValue:
'(ArrayList) [(ArrayList) [[Ljava.lang.String;@40b36b88, [Ljava.lang.String;@40b36c70]]
'Dim listsize As Int
'listsize = listSettingName.Size
For i = 0 To listSettingName.Size-1
Log("Read_tblSettings - Setting Name and Value: " & CRLF & listSettingName.Get(i) & " - " & listSettingValue.Get(i))
'Log shows...
'Read_tblSettings - Setting Name AND Value:
'(ArrayList) [[Ljava.lang.String;@40b352d8, [Ljava.lang.String;@40b35520] - (ArrayList) [[Ljava.lang.String;@40b36b88, [Ljava.lang.String;@40b36c70]
'mapSettings is a Process Global that is already initialized
mapSettings.Put(listSettingName.Get(i), listSettingValue.Get(i))
Next
'This returns null for varDebugState ? ! ? ! ? !
Log("mapSettings.Get('varDebugState') now: " & mapSettings.Get("varDebugState"))
End Sub