java.lang.ClassCastException

schimanski

Well-Known Member
Licensed User
Longtime User
I get the exception above, after loading a map-file in the following code:
B4X:
Sub ListViewDatenbank_ItemClick (Position As Int, Value As Object)   
  Dim a() As String 
  a= MapDatenbank.Get(Value)    <= Exception!!!!!!!!!!!
   
  EditText1.Text=Value
  EditText2.Text=a(0)
  EditText3.Text=a(1)
  EditText4.Text=a(2)

When I build a map with the following code, it runs without problems:

MapDatenbank.Put("Key1", Array As String("A", "B", "C"))
MapDatenbank.Put("Key2", Array As String("A", "B", "C"))
MapDatenbank.Put("Key3", Array As String("A", "B", "C"))

When I save the map with file.writemap and load it again with file.readmap, I get the error-message. How is it possible to read the different values in a string, after loading the map?

Thanks for help....
 

Penko

Active Member
Licensed User
Longtime User
Erel, I had some troubles with WriteMap/ReadMap before I realize maybe it can't handle class objects. Then I found this thread.

Because it's not written in the explanation of the function arguments, is RandomAccessFile.WriteObject able to cope with class objects?

I have a map which stores two class objects from the class tStyle.

B4X:
Dim obj as tStyle
Dim obj2 As tStyle

So, I want to save the Map to a file and then restore it.

Or, if RandomAccessFile.WriteObject is not capable of that, is there any way to do it?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…