B4J Question Best way to save different configurations from SQL file Data

Peter Lewis

Active Member
Licensed User
Longtime User
Hi All

I have a SQL file which the data changes depending on the use of the program. I initially thought that Save Map would work but there is no List of Maps unless I save a list of maps, but then I saw, saveList is converted to text.

Would it be better to Convert the list of maps to a string array and then saved as bytes ?

My SQL database has 40 fields and depending on which config is required will be the one loaded up.

I made a small test that works, there must be another way of doing this , seems convoluted

B4X:
    Dim listofmaps As List
    listofmaps.Initialize
        map.Put("test1","Firsttest")
        map.Put("test2","Second Test")
            listofmaps.Add(map)
   
        map.Initialize
        map.Put("test1","thirdtest")
        map.Put("test2","fourth Test")
            listofmaps.Add(map)

    Dim abc() As Byte = raf.ConvertObjectToBytes(listofmaps)
        File.WriteBytes(File.DirApp,"mylist.led",abc)  ' to -Hard Drive

        Dim listmaps() As Byte = File.ReadBytes(File.DirApp,"mylist.led") 'From Hard Drive
    Dim listmap As List = raf.ConvertBytesToObject(listmaps)

    For x = 0 To listmap.Size-1
        Dim pma As Map = listmap.Get(x)

        For i = 0 To pma.Size - 1
            Log("Key: " & pma.GetKeyAt(i))
            Log("Value: " & pma.GetValueAt(i))
        Next
    Next

Any suggestion would be helpful

Thank you
 
Last edited:

aeric

Expert
Licensed User
Longtime User
Maybe this is suitable for your use case :
 
Upvote 0

Peter Lewis

Active Member
Licensed User
Longtime User
Maybe this is suitable for your use case :
Thanks, I just remembered possibly DataTable makes a single object from SQL which can be converted to bytes and stored which will be a lot simpler to retrieve.
1718730335364.png


1718730444704.png
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Thanks, I just remembered possibly DataTable makes a single object from SQL which can be converted to bytes and stored which will be a lot simpler to retrieve.
View attachment 154714

View attachment 154715
I am not familiar with this library. I will argue that KVS is much simpler.

I also have another library call MinimaList to compliment with KVS which provide more methods but may not suitable for your case.
 
Upvote 0
Top