简体   繁体   中英

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

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 (eg, 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM