Android Question Map Collection question

Amalgamated Sugar

Member
Licensed User
I'm refactoring some code from another co-worker's project and came across this in the comments:

B4X:
'Again we are not initializing the map.
Dim Setupinfo As Map
Setupinfo = File.ReadMap(File.DirRootExternal, "Setup.txt")

Unfortunately, said co-worker no longer works here. So, I can't ask him. Can a map collection be initialized from File.ReadMap? And if it can, is it considered best practice?

I know that it can be done with CreateMap...
 
Last edited:

Yvon Steinthal

Active Member
Licensed User
It all depends on the use and the privacy of your map. Yes it works, is it best practice? It depends on what you do with it or more what the map holds as information.
File.DirRootExternal makes it editable by anyone holding the android device.
Makes sure you have the right syntax with that "Setup.txt" file. Have you tested it?
 
Upvote 0

Amalgamated Sugar

Member
Licensed User
Nevermind. After swimming through the code a little longer, 'Setupinfo' is a Process Global that gets initialized during Activity Create from a separate code module....

Sometimes, reading another person's code can be a challenge...
 
Upvote 0

Amalgamated Sugar

Member
Licensed User
I've addressed the possibility of moving the file with my applications manager and business analyst. Both have come back with the information not being sensitive. It sure would be easier to not have to request runtime permissions though...
 
Upvote 0

Yvon Steinthal

Active Member
Licensed User
In that case remember that it can be edited by the user, therefore making an error in the "File.ReadMap" function possible.
I suggest maybe surrounding your ReadMap in a Try Catch in order to "Catch" any file alteration.
 
Upvote 0
Top