[英]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 我试过了
file:///android_asset/uk.jpg
,但它不起作用
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.
它是ZIP存档中的一个条目,仅此而已。
Your options are: 您的选择是:
Open an InputStream
on the asset using open()
from AssetManager
, and pass that InputStream
to the library 使用
AssetManager
open()
在资产上打开InputStream
,并将该InputStream
传递给库
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 使用
AssetManager
open()
在资产上打开InputStream
,使用它将资产复制到某个位置(例如, 内部存储 ),然后将路径传递到刚创建的文件
Switch to a library that allows you to supply an InputStream
or is Android-aware and supports assets directly 切换到允许您提供
InputStream
或支持Android并直接支持资产的库
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.