android – 使用存储访问框架打开特定目录

android – 使用存储访问框架打开特定目录,第1张

概述我现在可以通过使用以下代码打开Lollipop文件选择器来获取文件URI: Intent intent = new Intent(); intent.setAction(Intent.ACTION_OPEN_DOCUMENT_TREE); startActivity(intent); 文件选择器在内部存储的根目录或我打开的最后一个目录中打开.如何让文 我现在可以通过使用以下代码打开Lollipop文件选择器来获取文件URI:
Intent intent = new Intent();            intent.setAction(Intent.ACTION_OPEN_document_TREE);            startActivity(intent);

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

解决方法 使用具有getExternalStorageDirectory()或getDataDirectory()等方法的Environment类
https://developer.android.com/reference/android/os/Environment.html.

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

private static final String filename = Environment            .getExternalStorageDirectory().getabsolutePath()            + "/pathTofile.jpg";
总结

以上是内存溢出为你收集整理的android – 使用存储访问框架打开特定目录全部内容,希望文章能够帮你解决android – 使用存储访问框架打开特定目录所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1135590.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存