3

In my app I am creating a pdf file in internal app files(data/data/package/files) I want these files to be readable when I read them using this code:

 Uri path = Uri.fromFile(pdfFile); 
 Intent pdfIntent = new Intent(Intent.ACTION_VIEW);
 pdfIntent.setDataAndType(path, "application/pdf");
 pdfIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

I have read about using openOutputStream() method but I have no clue how to read them through this.Could anyone help me?

EDIT

pdfFile--

    File    directory=getFilesDir();
    pdfFile=new File(directory,filename+".pdf"); 
Navdroid
  • 4,453
  • 7
  • 29
  • 47

2 Answers2

1

Pass MODE_WORLD_READABLE to openOutputStream() when writing the PDF to your internal storage. In theory, that will allow third party apps to read it.

Or, implement a ContentProvider for this file, such as the one I demonstrate in this sample project (here, copying a PDF from assets/ into internal storage).

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

Add this:
pdfFile.setReadable(true, false);

Sami
  • 669
  • 5
  • 20