简体   繁体   English

如何在资源文件夹中获取图像的字符串路径

[英]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: 您的选择是:

  1. Open an InputStream on the asset using open() from AssetManager , and pass that InputStream to the library 使用AssetManager open()在资产上打开InputStream ,并将该InputStream传递给库

  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 使用AssetManager open()在资产上打开InputStream ,使用它将资产复制到某个位置(例如, 内部存储 ),然后将路径传递到刚创建的文件

  3. 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.

相关问题 如何获取存储在android资产文件夹中的image(.png)文件的路径 - how to get the path of the image(.png) file that is stored in assets folder in android 如何将android Path字符串转换为Assets文件夹中的文件? - How to get the android Path string to a file on Assets folder? 如何在棉花糖设备上获取Picasa图像文件夹? - How can I get a Picasa image folder on my Marshmallow device? 如何更改资产文件夹的路径? - How to change path to assets folder? 如何在应用程序 package 中获取 Android 资产文件夹的路径 - How to get the path to the Android assets folder in the application package 如何在Android首次运行应用程序时将文件从我的资产文件夹复制到我的SD卡? - How can I copy a file from my assets folder into my SD card at first run of the app in Android? 如何显示资产文件夹中数据库中的数据并通过ListView进行查看 - How can i display the data in my database located in my assets folder and view it VIA ListView 我已经挂载了我的.obb文件,但如何获得资产的最终路径 - I have mounted My .obb file, but how to get the final path to my assets 如何获取存储在资产文件夹中的图像文件的最后修改日期? - How do i get the last modified date of image files stored in assets folder? 从资产文件夹检索图像路径 - Retrieve image path from assets folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM