Android Question File.WriteList -> convert to string -> why?

KMatle

Expert
Licensed User
Longtime User
I've never asked for the reason :)

As known File.WriteList will convert the values to strings. To me this makes no sense as a List can hold any data type.

Is there a reason for that behaviour? (Maybe because the written file is a textfile?)
 

DonManfred

Expert
Licensed User
Longtime User
You should use Randomaccessfile and here Writeb4xobject to write a List (with it´s items).

writelist0160.png
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
File.ReadList reads a text file and returns a list with its lines.
File.WriteList writes a list to a text file where each item is written to a separate line.

The answer to your question is that this is how these methods were designed (and documented).
This behavior will never change.

If you want to serialize a list then use B4XSerializator or RAF.WriteB4XObject. The result will be different. You will get a binary file.
 
Upvote 0
Top