Android Question Reading a MAP of a custom data type returns null fields

Geezer

Active Member
Licensed User
After creating a custom data type and filling a map with it I can access it fine.

However, after saving the file and reading it back in, the fields are inaccessible.

Any ideas ?

B4X:
Sub Process_Globals
    Type PieceInfo ( ID As String, Left As String, Length As String, Col1 As String, Col2 As String, Dir As String )
End Sub

Sub Globals
    Dim PieceMap As Map
    Dim PNumber As Int = 0
    
    Dim NumMap As Map
    
End Sub

Sub Activity_Create(FirstTime As Boolean)

    PieceMap.Initialize
    AddPiece( "1", "1", "3", "1", "2", "Forward" )
    AddPiece( "7", "1", "3", "1", "2", "Forward" )
    AddPiece( "3", "1", "3", "1", "2", "Forward" )

    For X = 0 To PieceMap.Size -1
        Dim PC As PieceInfo = PieceMap.Get( X )
        Log( X & " ID : " & PC.ID )
    Next

    File.WriteMap( File.DirInternal, "map.map", PieceMap )   
    
    Dim NewMap As Map = File.ReadMap( File.DirInternal, "map.map" )
    
    Log("LOADED")
    LogColor( NewMap , Colors.mAGENTA )

    For X = 0 To NewMap.Size -1
        Dim PC3 As PieceInfo = NewMap.Get( X )
        Log( X & " ID : " & PC3.ID )
    Next
    
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub AddPiece( vID As String, vLeft As String, vLength As String, vCol1 As String, vCol2 As String, vDir As String )
    Dim PI As PieceInfo
    PI.Initialize
    PI.ID = vID
    PI.Left = vLeft
    PI.Length = vLength
    PI.Col1 = vCol1
    PI.Col2 = vCol2
    PI.Dir = vDir
    PieceMap.Put( PNumber, PI )
    
    PNumber = PNumber + 1
End Sub
 
Top