msali Member Licensed User Longtime User Feb 25, 2018 #1 Hi, I have created a Map with a string as Key and List in Values - No issue. B4X: thisLst.InsertAt(typMapFld.Duration, 0) thisLst.InsertAt(typMapFld.SeqLength, 1) thisLst.InsertAt(typMapFld.Attempts, 2) thisLst.InsertAt(typMapFld.isCurrentStage, 3) thisLst.InsertAt(typMapFld.isCompleted, 4) ' thisMap.Put(key, thisLst) Then I save it using WriteMap B4X: File.WriteMap(SS_FilePath, "stages", thisMap) After Saving it I try to read it with ReadMap and try reading the list stored in value B4X: mapStages= File.ReadMap(SS_FilePath, "stages") thislst= mapStages.Get(key) I am unable to read the list properly. Where am I going wrong. Is this type of structure not allowed? Thanks in adv. Cheers
Hi, I have created a Map with a string as Key and List in Values - No issue. B4X: thisLst.InsertAt(typMapFld.Duration, 0) thisLst.InsertAt(typMapFld.SeqLength, 1) thisLst.InsertAt(typMapFld.Attempts, 2) thisLst.InsertAt(typMapFld.isCurrentStage, 3) thisLst.InsertAt(typMapFld.isCompleted, 4) ' thisMap.Put(key, thisLst) Then I save it using WriteMap B4X: File.WriteMap(SS_FilePath, "stages", thisMap) After Saving it I try to read it with ReadMap and try reading the list stored in value B4X: mapStages= File.ReadMap(SS_FilePath, "stages") thislst= mapStages.Get(key) I am unable to read the list properly. Where am I going wrong. Is this type of structure not allowed? Thanks in adv. Cheers
Erel B4X founder Staff member Licensed User Longtime User Feb 25, 2018 #2 See this video: This exact issue is discussed starting from 25:00 Upvote 0
DonManfred Expert Licensed User Longtime User Feb 25, 2018 #3 msali said: I am unable to read the list properly. Where am I going wrong. Click to expand... Check the documentation of File.WriteMap https://www.b4x.com/android/forum/pages/results/?query=File.WriteMap File. WriteMap (Dir As String, FileName As String, Map As Map) Creates a new file and writes the given map. Each key value pair is written as a single line. All values are converted to strings. Click to expand... You should use Randomaccessfile.writeb4xobject and Randomaccessfile.readb4xobject to read the map back. https://www.b4x.com/android/help/randomaccessfile.html#randomaccessfile_readb4xobject https://www.b4x.com/android/help/randomaccessfile.html#randomaccessfile_writeb4xobject Upvote 0
msali said: I am unable to read the list properly. Where am I going wrong. Click to expand... Check the documentation of File.WriteMap https://www.b4x.com/android/forum/pages/results/?query=File.WriteMap File. WriteMap (Dir As String, FileName As String, Map As Map) Creates a new file and writes the given map. Each key value pair is written as a single line. All values are converted to strings. Click to expand... You should use Randomaccessfile.writeb4xobject and Randomaccessfile.readb4xobject to read the map back. https://www.b4x.com/android/help/randomaccessfile.html#randomaccessfile_readb4xobject https://www.b4x.com/android/help/randomaccessfile.html#randomaccessfile_writeb4xobject
msali Member Licensed User Longtime User Feb 26, 2018 #4 Erel said: See this video: This exact issue is discussed starting from 25:00 Click to expand... Too good... I created a simple test project and it worked perfectly well. Now tomorrow I will embed it in my main project. Just Perfect. Thanks a lot. Upvote 0
Erel said: See this video: This exact issue is discussed starting from 25:00 Click to expand... Too good... I created a simple test project and it worked perfectly well. Now tomorrow I will embed it in my main project. Just Perfect. Thanks a lot.