I am trying to retrieve a reference to a file stored in the assets
directory to a file named myfile.pdf
. I have tried to do it as follows:
File file = new File("android_assest/myfile.pdf);
Log.d("myTag", "" + file.isFile());
Somehow, I get false
when the myfile.pdf
do exists in the assets
directory. I verified it using getAssets().list("")
and Log.d()
each element in the returned array.
More of which, I am trying to get a reference to a PDF file and then use any PDF viewer, which is already installed on the device, in order to view the PDF.
I guess that since the previous issue (retrieving a reference to the file) returns false
then the next snipped code fails:
Intent i = new Intent(Intent.ACTION_VIEW,
Uri.parse("file:///android_asset/myfile.pdf"));
startActivity(i);
Anyone has a clue why I am unable to retrieve a reference to the file? and why I cannot use already installed PDF viewer to display a PDF (after retrieving a reference to the PDF file)?
Thanks.