B4J Question How to write a multi-column list to disk

Mikelgiles

Active Member
Licensed User
Longtime User
Is multi-column not a good solution for small file storage when the ultimate destination is a tableview? Should I be using something different? The reason I am asking is that I am not finding many examples of reading and writing LIST. I got very good help with reading a csv file into a list but am now stuck with how to write data to a list. I was thinking a list would be easier than dealing with CSV but maybe I am wrong.
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Hello Mikel
To save a multi column list to a file is no easy task. the problem is storing OBJECTS (like the arrays) are not posible in simple files, to do it you may convert the list into bytes and then the bytes in to string.

The best way in my opinion to store a multi column list would be database (like SQLITE) or a simple CSV file is also good.
 
Upvote 0

Mikelgiles

Active Member
Licensed User
Longtime User
Hello Mikel
To save a multi column list to a file is no easy task. the problem is storing OBJECTS (like the arrays) are not posible in simple files, to do it you may convert the list into bytes and then the bytes in to string.

The best way in my opinion to store a multi column list would be database (like SQLITE) or a simple CSV file is also good.[
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Storing a list of arrays is also simple with B4XSerializator:
B4X:
Dim ser As B4XSerializator
'write to file
Dim out As OutputStream = File.OpenOutput(File.DirInternal, "1.dat", False)
Dim b() As Byte = ser.ConvertObjectToBytes(YourList)
out.WriteBytes(b, 0, b.Length)
out.Close
'read
Dim YourList As List = ser.ConvertBytesToObject(Bit.InputStreamToBytes(File.OpenInput(File.DirInternal, "1.dat")))
 
Upvote 0
Top