hi all
i receive a list of maps from a php server.
it s parsed very well and works fine
but then i save it to a text file in the activity_pause event using the file.writelist method
when i read it in the resume event i get the following error :
java.lang.ClassCastException: java.lang.String cannot be cast to anywheresoftware.b4a.objects.collections.Map$MyMap
You are writing a list. Each entry in this lit will be one line in the file.
But the list does not only store strings. It is carrying Maps.the map will be one STRING later in the written file... Reading this file back using readlist the maps (a string (one line) in the file) are not useable anymore.
Solution will be:
So you should use Randomaccessfile and use WriteObject with the list. Later readObject to get this list (of maps) back to b4a.
Note that WriteB4XObject is better than WriteObject. It is faster and more efficient. The only limitation of WriteB4XObject compared to WriteObject is that it doesn't support arrays of primitives types (except of bytes).