#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim tempmap, questionmap As Map
Dim tempnum As Int
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim readmap_button As Button
Dim savemap_button As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("main")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub readdata
If tempmap.IsInitialized = False Then tempmap.Initialize
If questionmap.IsInitialized = False Then questionmap.Initialize
tempmap.Clear
questionmap.Clear
tempmap = File.ReadMap(File.DirInternal,"questionmap.map")
tempnum = tempmap.Size-1 ' tempnum now holds the size of questionmap, how many items are stored in it
For lp = 0 To tempnum
questionmap.Put("Item #" &lp,"")
Next
questionmap = File.ReadMap2(File.DirInternal,"questionmap.map",questionmap)
'questionmap now contains the contents of saved questionmap in correct order
tempmap.Clear
tempnum = 0
Msgbox(questionmap,"Question map:")
End Sub
Sub savedata
If tempmap.IsInitialized = False Then tempmap.Initialize
If questionmap.IsInitialized = False Then questionmap.Initialize
tempmap.Clear
questionmap.Clear
Dim n As Int
For n = 1 To 20
questionmap.Put("Key word number " & n, "Value number " & n)
Next
File.WriteMap(File.DirInternal,"questionmap.map",questionmap)
Msgbox(questionmap,"Question map:")
End Sub
Sub savemap_button_Click
savedata
End Sub
Sub readmap_button_Click
readdata
End Sub