简体   繁体   English

我如何获取位于资产中的文件的uri

[英]how can I get uri of a file that located in assets

how can I get uri of a file that located in assets. 我如何获取位于资产中的文件的uri。 is there any way to get uri for a asset file? 有什么办法可以获取资产文件的uri?

Try this: 尝试这个:

String path = "file:///android_asset/file_name.mp3";

Uri uri = Uri.parse(path);

you can get by this way:: 您可以通过这种方式获得:

file:///android_asset/xyz.mp3
or
file:///android_asset/xyz.txt

There is no "absolute path for a file existing in the asset folder". 没有“资产文件夹中现有文件的绝对路径”。

You can use AssetManager object to get an InputStream 您可以使用AssetManager对象获取InputStream

Typeface face=Typeface.createFromAsset(getAssets(),"HandmadeTypewriter.ttf");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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