Why not just a simple Map?
According to the docs, a
map is "a collection that holds pairs of keys and values", while a
list is similar to a dynamic array where you can add and remove items from a list and it will change size accordingly.
In my application, I basically wanted a FIFO queue where I could append items to the list as required, and remove them, oldest first, when possible. A list just seemed a more natural fit (ie I'd have needed to do a lot more work if I used any other structure!).
Each data item is a simple (ie no arrays) JSON dataset, which by using objJSon.ToString effectively becomes a simple string (ie it no longer matters what's in the string).
Setting up the FIFO buffer is easy:
Dim Buffer As List
Buffer.Initialize
Adding an item to the FIFO buffer is easy:
Buffer.Add(objJSon.ToString)
Removing an item from the FIFO buffer is also easy:
item = Buffer.Get(0)
Buffer.RemoveAt(0)
Here's how I save the buffer to persistent storage:
File.WriteList(File.DirInternal, "buffer.txt", Buffer)
And here's how I load it back from persistent storage:
Buffer = File.ReadList(File.DirInternal, "buffer.txt")
Being a B4A newbie, it did take me a while to work all that out, but it's hard to imagine how the result could be any simpler.