Android Question open file pdf in folder DirAssets

Roberto P.

Well-Known Member
Licensed User
Longtime User
I can not open a pdf file in the folder File.DirAssets & "/products/product.pdf, there is an error or you can not open a file in that folder?

B4X:
Dim In As Intent
       
   
            In.Initialize(In.ACTION_VIEW, "file://" & aFile)
            In.SetType("application/pdf")
            In.SetComponent("android/com.android.internal.app.ResolverActivity")
           
            StartActivity(In)
 

walterf25

Expert
Licensed User
Longtime User
I can not open a pdf file in the folder File.DirAssets & "/products/product.pdf, there is an error or you can not open a file in that folder?

B4X:
Dim In As Intent
      
  
            In.Initialize(In.ACTION_VIEW, "file://" & aFile)
            In.SetType("application/pdf")
            In.SetComponent("android/com.android.internal.app.ResolverActivity")
          
            StartActivity(In)
I don't think you can open a file from the File.DirAssets folder, you may want to copy the file to either the internal folder or your package name folder.

Cheers,
Walter
 
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
copying the files in other directories can read the pdf file. I do not understand why can read images, html files but not read pdf file ?!
thanks
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I do not understand why can read images, html files but not read pdf file ?!
That´s the point. YOU (your app) can read the files from your assets. No matter what type of files.

But with the intent you start ANOTHER app which should show the file. This app do need access to your Assets or Internal files to read the file but it hasnt this permission.
So; if you relay on an external app the files should be copied to a place where the external app has access to this file. No matter if it is an Image, Textfile, PDF or whatever.
 
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
thanks DonManfred
clear.
So if I wanted to open the pdf file without an intent I would have no problems? As I read the html file with File object.
 
Upvote 0

Roberto P.

Well-Known Member
Licensed User
Longtime User
clear. I did not know. thanks

I prefer to open the pdf file with Intent because the available objects do not seem very efficient.
 
Upvote 0
Top