0

i'm trying to open a pdf on a button click. No errors pop up in the log but every time i click the button i get "E/tag: Rota.pdf (Read-only file system)" in the run log. i've tried changing the file system using using an adb command and that does nothing. any ideas?

  • Possible duplicate of [read file from assets](http://stackoverflow.com/questions/9544737/read-file-from-assets) – maulik Mar 08 '17 at 18:45

2 Answers2

0

Check that you have added the permission to read external storage in your manifest file.

< uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

Where is pdf file located ?

maulik
  • 150
  • 9
0

May this can be helpful to you.

If have a problem with opening PDF file, try below code.

File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() +"/"+ filename);
Intent target = new Intent(Intent.ACTION_VIEW);
target.setDataAndType(Uri.fromFile(file),"application/pdf");
target.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);

Intent intent = Intent.createChooser(target, "Open File");
try {
   startActivity(intent);
} catch (ActivityNotFoundException e) {
// Cathc exception here
}

or

You can try an ACTION_VIEW Intent with a Uri pointing to the file (either on the SD card or MODE_WORLD_READABLE in your app-local file store) and a MIME type of "application/pdf".

or

If you have a problem with Android Studio, debug and post useful log here.

Community
  • 1
  • 1
Dinesh M
  • 71
  • 1
  • 9