简体   繁体   中英

Read-Only File system android studio

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?

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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM