hmm...not working as well. is is because there's a problem with my loadfiles?
B4X:
Sub setToAddViews
to_save_views(0) = EditText1
to_save_views(1) = EditText2
to_save_views(2) = Lat
to_save_views(3) = Lon
to_save_views(4) = Time
End Sub
Sub load
If Not(File.Exists(File.DirRootExternal,"data.txt")) Then Return
Dim txt As String = File.ReadString(File.DirRootExternal,"data.txt")
txt = txt.Replace(" ", "")
Dim str() As String = Regex.Split(CRLF,txt)
If Not(str(str.Length-1).Contains(",")) Then Return
Dim str2() As String = Regex.Split(",",str(str.Length-1))
For i = 0 To to_save_views.Length-1
to_save_views(i).Text = str2(i)
Next
End Sub
Sub Save_click
Dim str As String = EditText1.text & "," & CRLF & EditText2.text & "," & CRLF & Lat.Text & "," & CRLF & Lon.Text & "," & CRLF & Time.Text
Dim writer As TextWriter
writer.Initialize(File.OpenOutput(File.DirRootExternal,"data.txt",True))
writer.WriteLine(str & CRLF)
writer.Close
Msgbox("Saved","")
End Sub
try this ... the data is written to file correctly
B4X:
Sub Save_Click
Dim str As String = EditText1.text & "," & EditText2.text & "," & Lat.Text & "," & Lon.Text & "," & Time.Text
Dim writer As TextWriter
writer.Initialize(File.OpenOutput(File.DirRootExternal,"data.txt",True))
writer.WriteLine(str & CRLF)
writer.Close
Msgbox("Saved","")
ReadFile
End Sub
Sub ReadFile
Dim TextReader1 As TextReader
TextReader1.Initialize(File.OpenInput(File.DirRootExternal, "data.txt"))
Dim line As String
line = TextReader1.ReadLine
Do While line <> Null
Log(line) 'read the result to logs
line = TextReader1.ReadLine
Loop
TextReader1.Close
End Sub
Still not working though. I am opening this file in notepad on my laptop it just shows it in a straight line. But when I open it in my phone, it shows a vertical motion. I do prefer it to be working on the laptop though. Here's an attachment of my coding. Not really sure what's wrong.
I'll look up to that. Any more to help in the problem I have? .txt files are not arranging accordingly as it is coded. There's must be something wrong with the code that I failed to notice.