In my app, I've got some pdf's stored in my assets folder. I've seen libraries for opening pdf-pages, but I think that apps such as quickoffice are better at showing the pdf's than the libraries I've seen. Therefore, i wish to show the pdf using Intent.ACTION_VIEW
, like this:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(fileUri, "application/pdf");
getActivity().startActivity(intent);
However, this is not possible because third party apps are not allowed to acces files in my package. Therefore I need to copy the files to the external storage and provide that file to the intent.
That brings my to my question: my pdf's are quite big in size, so I think it'd be stupid to store them twice (once in my assets folder and once on the external storage). So I'm wondering if there is a work-around for this. Could i for example do:
//Copy file to external storage
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(fileUri, "application/pdf");
getActivity().startActivity(intent);
//Delete file from external storage
Is this a good work-around or will this cause problems with the pdf-viewing app? Or is there a different work-around?