Android Question read list of maps from text file

le_toubib

Active Member
Licensed User
Longtime User
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

what am i doing wrong ?
 

DonManfred

Expert
Licensed User
Longtime User
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.
 
Upvote 0
Top