Home » Android » ioexception when opening uri from external app

ioexception when opening uri from external app

Posted by: admin November 1, 2017 Leave a comment


From activity 1, I use an intent

Intent i = new Intent(Intent.ACTION_GET_CONTENT);
    startActivityForResult(Intent.createChooser(i, "Pick a file"), REQUEST_CODE_UPLOAD_FILE_FOR_IMPORT);
    }catch (android.content.ActivityNotFoundException ex){
           Log.e("Error","FileManager not found!");

and process the URI and extract data from the document. once I do so, I pass the extracted data and the URI to activity 2, where the user can see the data. the user also has the option of opening the original file from activity 2 and I do the following:

public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW, getUri());
                PackageManager packageManager = activity.getPackageManager();
                List activities = packageManager.queryIntentActivities(intent,
                boolean isIntentSafe = activities.size() > 0;

but whatever external app I choose gets an io Exception. how can I get them to open my document?


Looks like second app does not have permissions to read the file.

For Reading spreadsheets Google have API for same.API Details or Spreadsheet Service might help you.