Dear All,
If I read a JSON array from SQL:
(I excluded alot of code which I consider not relevant to explain this)
It all works well, and the file written to shows exactly what it should.
If I then afterwards use File.Readlist to read the file, it also looks good, BUT when I try to use the map object "m =" as above for the lines read from the file, I get:
java.lang.ClassCastException: java.lang.String cannot be cast to anywheresoftware.b4a.objects.collections.Map$MyMap
A look with msgbox at the lines in the file with the file show no difference between what´s being retrieved from the server, BUT if I use a msgbox, as in the above, to see what´s in the map object, the lines read from the server starts with "(MyMap)", whereas when they´ve been written to the file, they start with "(String)", and I´m positive that this is where the problem is. Any idea how this can be resolved?
Another weird thing is that the file is not written to the external sd card, but internally on the phone. This could be due to using an AVD emulator though, which however indeed is set up with a 2GB card.
Thanks in advance!
If I read a JSON array from SQL:
B4X:
Dim Messages As List
Type Fivelines (msg_Subject As String,msg_Message As String, msg_Timestamp As String, msg_Sender As String, msg_threadid As String,msg_msgtype As Int,msg_username As String, msg_notify As String, msg_id As String, msg_count As String)
Dim Messages as List
Dim tl As Fivelines
Messages = parser.NextArray
If Messages.Size > 0 Then
Dim i As Int
Dim m as Map
For i = 0 To (Messages.Size - 1)
m = Messages.Get(i)
tl.msg_subject = m.Get("subject")
msgbox (m,"")
next
File.WriteList(File.DirDefaultExternal, "/headers.txt", Messages)
(I excluded alot of code which I consider not relevant to explain this)
It all works well, and the file written to shows exactly what it should.
If I then afterwards use File.Readlist to read the file, it also looks good, BUT when I try to use the map object "m =" as above for the lines read from the file, I get:
java.lang.ClassCastException: java.lang.String cannot be cast to anywheresoftware.b4a.objects.collections.Map$MyMap
A look with msgbox at the lines in the file with the file show no difference between what´s being retrieved from the server, BUT if I use a msgbox, as in the above, to see what´s in the map object, the lines read from the server starts with "(MyMap)", whereas when they´ve been written to the file, they start with "(String)", and I´m positive that this is where the problem is. Any idea how this can be resolved?
Another weird thing is that the file is not written to the external sd card, but internally on the phone. This could be due to using an AVD emulator though, which however indeed is set up with a 2GB card.
Thanks in advance!