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?
            Asked
            
        
        
            Active
            
        
            Viewed 1,365 times
        
    0
            
            
        - 
                    Possible duplicate of [read file from assets](http://stackoverflow.com/questions/9544737/read-file-from-assets) – maulik Mar 08 '17 at 18:45
2 Answers
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.
- 
                    The code seems to be fine. i can click my button but nothing happens the only log message i get is the read only file system one – Ryan Hunter Mar 08 '17 at 18:50
- 
                    
- 
                    out = new FileOutputStream(file.getName()); stores the path. used a breakpoint to check this and it's fine – Ryan Hunter Mar 08 '17 at 18:56
- 
                    May be the below link works for you http://stackoverflow.com/questions/17085574/read-a-pdf-file-from-assets-folder – Dinesh M Mar 08 '17 at 18:57
 
     
    