Android Question Questions about text files

kuosda

Active Member
Licensed User
Longtime User
Code1:
'SavePath = File.DirRootExternal & "/UpJpgToFTP"
    Dim outStream As OutputStream
    Dim txtWrite As TextWriter
    outStream = File.OpenOutput(SavePath,"Test.txt",True)
    txtWrite.Initialize2(outStream,"BIG5")    '編碼
    txtWrite.WriteLine(EditText1.text & Chr(13))
    txtWrite.Flush
    txtWrite.Close
    outStream.Close



Code2:
If PhoneMsg.SdkVersion >= 23 Then
        rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
        Wait For Activity_PermissionResult (Permission As String, PResult As Boolean)
        If Permission = rp.PERMISSION_WRITE_EXTERNAL_STORAGE Then
            If PResult = False Then
                MsgboxAsync("Disagree Storage Rights APP will not be able to be run", "Message")
                Activity.Finish
            End If
        End If
    End If
Code1: Is a simple code
Code2: Confirm permissions

Using Code1 I write the first line of text in Android, Android can read, connect the PC can also read, but, after the second line of text can be read in Android, connected to the PC but can not read, the new text segment, must be re-turned on Andorid, the PC can read, what is going on? How to solve?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Don't use TextWriter. Especially not for this case where you want to change the end of line character.

The correct solution is to use a proper editor on your PC that can handle Linux types end of lines (Notepad++).

The other option is to create a string with the end of lines that you like and write it with File.WriteString.
 
Upvote 0
Top