124697
124697

Reputation: 21893

How can I get a string path of an image in my assets folder

I need to pass a third party library the path of an image that is stored in my assets folder

I have read a few answers but none helped. I have tried file:///android_asset/uk.jpg and it doesn't work

Upvotes: 0

Views: 75

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006564

I need to pass a third party library the path of an image that is stored in my assets folder

There is no path. Your asset is not a file. It is an entry in a ZIP archive, nothing more.

Your options are:

  1. Open an InputStream on the asset using open() from AssetManager, and pass that InputStream to the library

  2. Open an InputStream on the asset using open() from AssetManager, use that to copy the asset to some location (e.g., internal storage), then pass the path to the file that you just created

  3. Switch to a library that allows you to supply an InputStream or is Android-aware and supports assets directly

Upvotes: 1

Related Questions