如何获得资源文件夹的URI?如何获得、文件夹、资源、URI

2023-09-06 13:11:47 作者:毁我爱她、你真奇葩

我想获得的图像我在绘制文件夹的URI。我试了很多可能的方法,但似乎没有任何工作。任何人都可以建议我如何获得资源文件夹的URI。任何帮助是非常AP preciated。

I am trying to get the Uri of an image I have in the drawable folder. I tried many possible ways but nothing seems to work. Can anyone suggest me how to get the Uri of res folder. Any help is much appreciated.

推荐答案

嗯,这其实很简单。基础URI在你的包的资源将类似于以下可能性:

Well, it's actually quite easy. a base URI for a resource in your package would be something like the following possibilities:

android.resource://[package]/[resource_id]
android.resource://[package]/[res type]/[res name]

所以,下面的是易于管理。

So the following would be managable.

Uri path = Uri.parse("android.resource://com.segf4ult.test/" + R.drawable.icon);
Uri otherPath = Uri.parse("android.resource://com.segf4ult.test/drawable/icon");

您可以找到更多关于这个在http://androidbook.blogspot.com/2009/08/referring-to-android-resources-using.html

You can find more about this at http://androidbook.blogspot.com/2009/08/referring-to-android-resources-using.html