Android Question Save and auto Load Text

Sergey_e

Member
Guys, help the beginner.
I want to write a simple program. Text field and button.
We write a short word in the text field. Press the button and save the word.
I would like to save the text and put it in the text box when you open the program.
Tried different code. Nothing works.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Tried different code. Nothing works.
You need to show us what you have tried and tell us what happened.

B4X:
Sub Activity_Create (FirstTime As Boolean)
  Activity.LoadLayout("1")
  If FirstTime Then
    If File.Exists(File.DirInternal, "1.txt") Then
      EditText1.Text = File.ReadString(File.DirInternal, "1.txt")
    End If
  End If
End Sub

Sub Button1_Click
 File.WriteString(File.DirInternal, "1.txt", EditText1.Text)
End Sub
 
Upvote 0
Top