Android Question Write and read Map

Colin Evans

Active Member
Licensed User
Longtime User
Hi, I'm having problems with getting my head around saving a map in one sub routine and the reading it back into another subroutine

B4X:
    RatesChk.Initialize
        For i = 0 To Count - 1
            Dim str As Map = results.Get(i)
            Dim strVar As String = str.Get("valid_from")
            'FromChk= strVar.SubString2(0,10)
            invChk = str.Get("value_inc_vat")
            If invChk = "" Then invChk="0.00"
            tim0Chk = str.Get("valid_from")
            tim0Chk = tim0Chk.SubString2(11,16)
            RatesChk.Put(tim0Chk, invChk)
        Next
File.WriteMap(File.DirInternal, "Rates.txt", RatesChk)

and reading it back in with

B4X:
                    RatesChk= File.ReadMap(File.DirInternal, "Rates.txt")

What's puzzling me is sometimes it works but very rarely, I don't have an SDCard in the phone as the internal memory is 256Gb, I've tried all the other Dir options but getting nowhere, is it possible to not read and write to storage and just have the data in a Map accessible to all subroutines in the module, the map only has 48 entries and contains new data every time an option is chosen
 

Colin Evans

Active Member
Licensed User
Longtime User
Thanks Klaus (and everyone else who's advised me) I've re done my code as you suggested and now it all works, thanks again, no doubt I'll be back when I try something else
 
Upvote 0
Top