I am trying to get file from external storage, then I have to send that file to pdf readers using intents. Previously below code was working fine but after installing Android 6 (Marshmallow update), my code is not working and getting a toast message
"This file could not be accessed Check the location or the network and try again."
(This is due to new android runtime permissions). I just tried all the solutions (Content Providers etc but not working) Any Solutions?
File file = new File(getFilesDir(), "myfile.pdf");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
Intent intentChooser = Intent.createChooser(intent, "Choose Pdf Application");
try {
startActivity(intentChooser);
} catch (ActivityNotFoundException e) {
//com.adobe.reader
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=com.adobe.reader")));
}