1

I have a pdf file placed in my assets folder and I am firing an intent to read it. Here is my code :

 Uri path = Uri.parse("file:///android:asset/about.pdf");
   Intent intent  = new Intent(Intent.ACTION_VIEW);
   intent.setDataAndType(path, "application/pdf");
   intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
   startActivity(intent);

When I do this, apop up appears with list of applications including adobe reader but when I click on it, a dialog appears saying :"Error", the file path is not valid

Please tell me how to fix this

Ankit
  • 4,426
  • 7
  • 45
  • 62

1 Answers1

1

Is this file in your app's assets folder? If it is, then your URI is wrong, check out this question:

How to open a pdf stored either in res/raw or assets folder?

there's an answer describing how to construct a proper URIs for your assets.

Community
  • 1
  • 1
devmiles.com
  • 9,895
  • 5
  • 31
  • 47