【问题标题】:Open Specific Directory Using Storage Access Framework使用存储访问框架打开特定目录
【发布时间】:2015-07-18 20:44:09
【问题描述】:

我目前可以通过使用以下代码打开 Lollipop 文件选择器来获取文件 URI:

            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_OPEN_DOCUMENT_TREE);
            startActivity(intent);

文件选择器在内部存储的根目录或我打开的最后一个目录中打开。 如何让文件选择器显示特定目录的内容? 例如,我可能希望文件选择器在启动后显示下载文件夹的内容,如下图所示。

【问题讨论】:

  • 你找到解决办法了吗?
  • @VadimStar 还没有 :(。不过,我最近没有积极开发 Android。

标签: android android-intent android-5.0-lollipop storage-access-framework


【解决方案1】:

使用具有getExternalStorageDirectory()getDataDirectory() 等方法的Environmenthttps://developer.android.com/reference/android/os/Environment.html

如果图像存储在变量中,则从该路径获取它们:

private static final String fileName = Environment
            .getExternalStorageDirectory().getAbsolutePath()
            + "/pathToFile.jpg";

【讨论】:

  • getExternalStorageDirectory() 已被弃用。
猜你喜欢
  • 2014-09-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多