user3810513
user3810513

Reputation: 3

How to giving address from assets folder?

I intend opening a PDF file with the default application of my device. I have a problem giving address from the assets folder.
My giving address code is as follows:

File pdfFile = new File("file:///android_assets/test.pdf");
    Uri path = Uri.fromFile(pdfFile);
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.setDataAndType(path, "application/pdf");
    startActivity(intent);

This code gives the error This path is not valid when Adobe Reader opens. What's the correct address?

Upvotes: 0

Views: 77

Answers (1)

Blackbelt
Blackbelt

Reputation: 157437

It shows the error because only your application have the permission to access that folder. You can think to copy the file in a different directory (e.g. some place in the sdcard) and provide acrobat reader with the uri to the copied file,

Upvotes: 1

Related Questions