Need Help

baron159

Member
Licensed User
Longtime User
Hey guys,
I'm making a game and wanted to know my options for saving a list of variables and then reading then at a certain event.

I wanted to know what my options are and your opinion on what should be done.

The list of variables is just numbers and strings nothing to complex.

Thanks for the help,
Baron159
 

eps

Expert
Licensed User
Longtime User
Are you looking to save these and use them the next time the App starts, or inside the App.

Your Q is a little vague!!

If you want to store and then be able to restore values, I would use a DB, but then that's what I know best. Others may use a File, which can be used or...

A lot depends on the use of the strings or numbers and how they relate...
 
Upvote 0

baron159

Member
Licensed User
Longtime User
Are you looking to save these and use them the next time the App starts, or inside the App.

Your Q is a little vague!!

If you want to store and then be able to restore values, I would use a DB, but then that's what I know best. Others may use a File, which can be used or...

A lot depends on the use of the strings or numbers and how they relate...

Im looking for something that saves the data when the user hits save and something that reads the data when the user hits load. Also where could I find and example of this. If you could, could you upload an example program.
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
The example code below will save the data entered into two EditText fields. The fields it saves are EditText1 and EditText2.

B4X:
Sub Globals
      Dim sets As Map
      sets.Initialize
End Sub

Sub savebtns
      sets.Clear
      sets.Put("EditText1", EditText1.Text)
      sets.Put("EditText2", EditText2.Text)
      File.WriteMap(File.DirInternal, "btnset.set", sets)
End Sub

Sub loadbtns
      sets = File.ReadMap(File.DirInternal, "btnset.set")
      EditText1.Text = sets.Get("EditText1")
      EditText2.Text = sets.Get("EditText2")
End Sub
 
Upvote 0

baron159

Member
Licensed User
Longtime User
The example code below will save the data entered into two EditText fields. The fields it saves are EditText1 and EditText2.

B4X:
Sub Globals
      Dim sets As Map
      sets.Initialize
End Sub

Sub savebtns
      sets.Clear
      sets.Put("EditText1", EditText1.Text)
      sets.Put("EditText2", EditText2.Text)
      File.WriteMap(File.DirInternal, "btnset.set", sets)
End Sub

Sub loadbtns
      sets = File.ReadMap(File.DirInternal, "btnset.set")
      EditText1.Text = sets.Get("EditText1")
      EditText2.Text = sets.Get("EditText2")
End Sub

Doing it this way....where would it save the .txt file to in the android file system?
 
Upvote 0
Top