mardi 12 mai 2015

Unable to open PDF from app folder

I am trying to save pdf files on to app folder and retrieve thereafter using an Intent.

File directory = context.getDir("myFolder", Context.MODE_PRIVATE);
File outputFile = new File(directory, pdfFileName);
filePOJO.setPDFLocation(outputFile);

//download and save data using outputstream

Log.i(TAG_NAME, "pdf file exist ? " + outputFile.exists()); //returns true

Everything works as expected and I can see the file exists from the log.

Now I am opening this file using intent. Here is how I do it.

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(filePOJO.getPDFLocation()), "application/pdf");
startActivity(intent);

Upon running on a device, it opens Adobe Reader and displays "The document path is not valid". I double checked read permissions on AndroidManifest.xml

Can't really find what's blocking? Did I miss anything?

Aucun commentaire:

Enregistrer un commentaire