Android Question Storing a list as txt file

harinder

Active Member
Licensed User
Longtime User
Hello,
I am just a noob in b4a..just started learning..
I have a small issue. The user enters text in edittext and presses button1. the text gets added to a list. After adding a few, he presses button2 to write list to a text file. the problem is....only last item of list is getting stored in text file..What am i doing wrong here?

Thank you for your patient reply,,


B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim list1 As List
    Private Button1 As Button
    Dim EditText1 As EditText
    Private Button2 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("spinner")
    If FirstTime Then
    If File.Exists(File.DirRootExternal, "Init.txt") = False  Then
        File.Copy(File.DirAssets, "Init.txt", File.DirRootExternal, "Init.txt")
    End If
    End If
    EditText1.TextColor=Colors.Black
   
   
End Sub

Sub Button1_click
   
    list1.Initialize
    If EditText1.Text <> "" Then
    list1.add(EditText1.Text)
    End If
    EditText1.Text=""
   
End Sub
Sub Button2_click
    File.Writelist(File.DirRootExternal , "Init.txt",list1)
   
End Sub
 
Top