I have an App that downloads a PDF file and stores it with MODE_PRIVATE (for security purposes) on the Internal Memory of the App:
FileOutputStream fos = getApplicationContext().openFileOutput(LOCAL_FILE_NAME, Context.MODE_PRIVATE);
InputStream inputStream = entity.getContent();
byte[] buffer = new byte[1024];
int bufferLength = 0;
while((bufferLength = inputStream.read(buffer)) > 0) {
fos.write(buffer, 0, bufferLength);
}
fos.close();
How can I open and display the downloaded PDF file? I have been searching in StackOverflow and I haven't found a clear solution for this.
It seems that the problem is that Android doesn't has native support to open PDF files, so I think that there are two options:
Use some external library to displays PDF files. Is there any that works well?
Launch an Intent to show the PDF file, but it seems that the files stored as MODE_PRIVATE can't be opened by external Apps. I have found some solutions that copies the file to the external memory and then launches the Intent, but this procedure breaks the security purpose of the MODE_PRIVATE option, right?
Thanks for reading