Android Question Problem on DirDefaultExternal

imak123

Member
I want to write file to external storage on my emulator, however I meet the following error. Do I need to get permission to write file on external storage ?
Thanks
Mak

Error : java.io.FileNotFoundException: /storage/emulated/0/Android/data/b4a.example/files/introb4a.txt (No such file or directory).....

Code :

B4X:
Private Sub btWrite_Click
Dim fdName,tarDir As String

    tarDir = File.DirDefaultExternal

    fdName = "introb4a.txt"

    'Write to external

    If File.ExternalWritable Then

        File.WriteList(tarDir,fdName,contList) -< Error Occur here !

        ToastMessageShow("Just save the file",False)

    Else

        ToastMessageShow("Cannot Save the File",False)

      
    End If

End Sub
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
It is very simple: whenever you see code with File.DirDefaultExternal or File.DirRootExternal you know that the code will not work.

 
Upvote 0
Top