0

hi i want the path to a file in my android assets folder.

How I get the path as String?

I try with :

String path = getClass().getClassLoader().getResource("file:///android_asset//psp.pdf").getPath();

I need the path as String.

Tarasov
  • 3,625
  • 19
  • 68
  • 128
  • 1
    possible answer http://stackoverflow.com/questions/8474821/how-to-get-the-android-path-string-to-a-file-on-assets-folder . tl;dr, it's not possible. – Nikita Shaposhnik Mar 09 '17 at 11:40
  • http://stackoverflow.com/questions/4820816/how-to-get-uri-from-an-asset-file – IntelliJ Amiya Mar 09 '17 at 11:42
  • 1
    Possible duplicate of [How to get the android Path string to a file on Assets folder?](http://stackoverflow.com/questions/8474821/how-to-get-the-android-path-string-to-a-file-on-assets-folder) – Akshay Tilekar Mar 09 '17 at 11:43

1 Answers1

0

The only ways to access an asset are:

  • Via open() on AssetManager, in which case your path is psp.pdf

  • Via file:///android_asset/ in WebView, in which case your path is file:///android_asset/psp.pdf

An asset is neither a file on a filesystem nor something that you get from a ClassLoader.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491