Android Question location of String.txt at internal storage

rogel a. tolentino

Member
Licensed User
B4X:
File.WriteString(File.DirInternal, "String.txt", "This is some string" & CRLF & "and this is another one.")
B4X:
Msgbox(File.ReadString(File.Dirinternal, "String.txt"), "string.txt")

the above codes are succesful and I already view the data of string.txt using msgbox.
I tried to find string.txt at the internal storage using file manager but failed.
Where can I view the said file?
 

rogel a. tolentino

Member
Licensed User
B4X:
    'Main.Reader.Initialize(File.OpenInput(File.DirRootExternal, "customer.txt"))
    Main.Reader.Initialize(File.OpenInput(Main.folder, "customer.txt"))
    Dim linec As String
    Dim tmp2a() As String
    linec = Main.Reader.ReadLine
    arrsize1=0
    Do While linec <> Null
        tmp2a = Regex.Split("\,",linec)
        arrsize1=arrsize1+1
        For arr2 = 1 To 26+1
            If arr2=27 Then Exit
            customer(arrsize1, arr2) = tmp2a(arr2 - 1)        Next
        linec = Main.Reader.ReadLine
    Loop
    Main.Reader.Close
    sizecust = arrsize1

    Main.Reader.Initialize(File.OpenInput(Main.folder, "rate.txt"))

Why is it the last line has error rate.txt and customer.txt are located in same folder /storage/emulated/0/Android/data/b4a.mrs/files

form1_activity_create (java line: 460)
java.io.FileNotFoundException: /storage/emulated/0/rate.txt (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:214)
at b4a.mrs.form1._activity_create(form1.java:460)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:191)
at b4a.mrs.form1.afterFirstLayout(form1.java:104)
at b4a.mrs.form1.access$000(form1.java:17)
at b4a.mrs.form1$WaitForLayout.run(form1.java:82)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6146)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Don't use TextReader at all. Use File.ReadLines instead.

Why is it the last line has error rate.txt and customer.txt are located in same folder /storage/emulated/0/Android/data/b4a.mrs/files
The file is not there. Maybe you named it Rate.txt or something similar. You can use File.Exists to check whether a file exists.
 
Upvote 0
Top