I can get the file from my asset folder like this
Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.parse("file:///android_asset/help_doc.pdf"), "application/pdf");
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try{
startActivity(i);
}catch(ActivityNotFoundException e){
Toast.makeText(this, "No Application Available to View PDF", Toast.LENGTH_SHORT).show();
}
but when I select the application to open it, it either does not open or gives me an error saying error opening file. it does not exist or cannot be read but if i put it on my sdcard and click on it to open it I dont get this error so whats wrong with how I am doing it?
file://android_assetonly works in your app. What you are telling these others apps to do is to readhelp_doc.pdfout of their assets, and they do not have such a file.You will need to either:
ContentProviderto make it available to the PDF viewing appThis sample project demonstrates the latter approach.