【问题标题】:What is the path directory to res/drawable type String to pass through File(String path) in Android?在Android中通过文件(字符串路径)的res / drawable类型String的路径目录是什么?
【发布时间】:2014-06-02 02:27:21
【问题描述】:

我正在尝试获取 res/drawable 中图像的字符串路径目录并通过它进行过滤(jpg、png ..) 像这样的

    File folder = new File("/res/drawable");
    images = folder.listFiles(IMAGE_FILTER);
    File image = images[randGen.nextInt(images.length)];

来自 sd 卡的工作很容易,但无法从资源文件夹中获取!我不知道这是否是一个幼稚的问题,但我一直在尝试不同的选项,比如通过 uri、将位图转换为文件,没有运气!

【问题讨论】:

标签: android path directory android-drawable


【解决方案1】:

我正在尝试获取 res/drawable 中图像的字符串路径目录

资源不是设备上的文件。它们是 APK 的 ZIP 文件中的条目。因此,您不能构造指向资源的File

您可以使用AssetManager列出资产,在资产上打开InputStreams等。

【讨论】:

    猜你喜欢
    • 2020-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多