Fairly new here and been trying to work with Map all day. I am trying to achieve a couple things. First is I want to save user settings in my app (specifically units of measure: Lbs or Kg), and also the status of a checkbox. I will also need to store the strings of edittext boxes and later retrieve those strings.
Here's my code regarding the checkbox:
Sub Process_Globals
Dim Map1 As Map
End Sub
Sub Globals
Dim chkFavStartup As CheckBox
Dim settingsFav As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
Map1.Initialize
Map1.Put("settingsFav","False")
File.WriteMap(File.DirInternal,"Map.txt",Map1)
End If
Activity.LoadLayout("main")
Map1 = File.ReadMap(File.DirInternal,"Map.txt")
chkFavStartup.Initialize("")
settingsFav = Map1.Get("settingsFav")
If settingsFav = "True" Then
chkFavStartup.Checked = True
Else
chkFavStartup.Checked = False
End If
Sub btnSaveSettings_Click
Map1.Initialize
If chkFavStartup.Checked = True Then
Map1.Put("settingsFav","True")
Else
Map1.Put("settingsFav","False")
End If
File.WriteMap(File.DirInternal, "Map.txt", Map1)
ToastMessageShow("Settings Saved",False)
End Sub
So I'm not getting any errors, but it's not working either. I have the app installed on my phone, but the checkbox won't stay checked when I restart the app. What am I doing wrong?
Here's my code regarding the checkbox:
Sub Process_Globals
Dim Map1 As Map
End Sub
Sub Globals
Dim chkFavStartup As CheckBox
Dim settingsFav As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
Map1.Initialize
Map1.Put("settingsFav","False")
File.WriteMap(File.DirInternal,"Map.txt",Map1)
End If
Activity.LoadLayout("main")
Map1 = File.ReadMap(File.DirInternal,"Map.txt")
chkFavStartup.Initialize("")
settingsFav = Map1.Get("settingsFav")
If settingsFav = "True" Then
chkFavStartup.Checked = True
Else
chkFavStartup.Checked = False
End If
Sub btnSaveSettings_Click
Map1.Initialize
If chkFavStartup.Checked = True Then
Map1.Put("settingsFav","True")
Else
Map1.Put("settingsFav","False")
End If
File.WriteMap(File.DirInternal, "Map.txt", Map1)
ToastMessageShow("Settings Saved",False)
End Sub
So I'm not getting any errors, but it's not working either. I have the app installed on my phone, but the checkbox won't stay checked when I restart the app. What am I doing wrong?