如何获得资源文件夹的URI? [英] How to get Uri of res folder?

查看:111
本文介绍了如何获得资源文件夹的URI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得的图像我在绘制文件夹的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");

您可以找到更多关于这个在<一个href="http://androidbook.blogspot.com/2009/08/referring-to-android-resources-using.html">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

这篇关于如何获得资源文件夹的URI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆