Android Question Open a file with his application

Mahares

Expert
Licensed User
Longtime User
You cannot open the file in Dir.Assets, but you can copy it first to File.DirDefaultExternal or File.DirRootExternal. Note file name in lowercase like: myfile.ext. See below code:
B4X:
Dim i As Intent
If File.Exists(File.DirDefaultExternal,"help0.pdf")=False Then  
        File.Copy(File.DirAssets,"help0.pdf",File.DirDefaultExternal,"help0.pdf") 'file name in lowercase
End If
i.Initialize(i.ACTION_VIEW, "file://" & File.DirDefaultExternal & "/help0.pdf")
i.SetType("application/pdf")
StartActivity(i)
 
Upvote 0
Top