机器人 - 获取资源的路径机器人、路径、资源

由网友(捧恠手吢裡の臸噯)分享简介:我的问题是:是否有可能得到的资源的绝对路径(在res /文件夹中的子目录)在Android中My question is: is it possible to get the absolute path of a resource (in a subdirectory of the res/ folder) in...

我的问题是:是否有可能得到的资源的绝对路径(在res /文件夹中的子目录)在Android中

My question is: is it possible to get the absolute path of a resource (in a subdirectory of the res/ folder) in Android?

大多数我看到在谷歌这个问题的答案的建议得到一个文件描述符,这意味着,这是不可能的。

Most of the answers I see to this question on google suggest getting a file descriptor, implying that this is not possible.

是吗?

编辑:我想这样做的原因是因为我正在写接受路径媒体播放类。测试将容易得多,如果我能通过资源的绝对路径。

The reason I want to do this is because I'm writing classes that accept a path to media and play it. Testing would be much easier if I could pass the absolute path of a resource.

推荐答案

不可能的。您所看到的资源文件夹被编译到apk文件,它甚至有可能不会保存,因为它是。 (例如,这些布局的XML文件不再XML文件一旦被编译)

Not possible. The resource folder you see is compiled into the apk, and it may not even store as it is. (e.g. those layout xml files are no longer xml files once it is compiled)

有两种可能的解决方案/变通您的具体情况:

Two possible solution/work-around for your situation:

与推SDK工具,你需要一个已知位置(如到/ mnt / SD卡/ ...)文件 创建一个样机提供商媒体装载机接受的东西,在原料资源,而不是路径,为您的测试目的
阅读全文

相关推荐

最新文章