android - Path of PDF Viewer Library -


i using pdf viewer library view pdf inside android app. i've browsed through lot of tutorials, 1 of dipak's tutorial. want access pdf file stored in assets folder instead of accessing external storage. problem is, can't "path" right. return file not found.

i've tried following, still yields same result:

  • this.getassets()
  • file:///android_assets/file_name.pdf
  • file:///android_asset/file_name.pdf

you can't path asset, have right in sd or internal memory path.

for sd card

first take permission

<uses-permission android:name="android.permission.write_external_storage" /> 

then write in card

 file f = new file(environment.getexternalstoragedirectory() + "file.pdf");   if (!f.exists()) try {      inputstream = getassets().open("file.pdf");     int size = is.available();     byte[] buffer = new byte[size];     is.read(buffer);     is.close();       fileoutputstream fos = new fileoutputstream(f);     fos.write(buffer);     fos.close();   } catch (exception e) { throw new runtimeexception(e); }    staring path = f.getpath();  

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -