gpt4 book ai didi

android - 如何使用存储访问框架访问 "/"(根)目录

转载 作者:行者123 更新时间:2023-11-29 19:29:24 27 4
gpt4 key购买 nike

在查看 GitHub 上的 Google 示例后,我试图在 Android 7.0 及更高版本上使用 Storage Access Framework 访问 "/"(根)目录,我可以看到在使用 StorageVolume 类创建 accessIntent 时只传递了预定义的目录,但是如何访问这些预定义目录以外的任何其他目录?

这是我试过的代码:

    StorageManager storageManager = (StorageManager) getSystemService(Context.STORAGE_SERVICE);
File root = new File("/");
StorageVolume storageVolume = storageManager.getStorageVolume(root);

Intent intent = storageVolume.createAccessIntent("/");
startActivityForResult(intent, REQUEST_CODE);

我的 storageVolume 为空,无法使用 StorageVolume 框架访问“/”目录。

How to get Scoped Directory Access to "/" directory using Storage Access Framework on Android 7.0 and above?

最佳答案

如果设备未获得 Root,则无法访问根文件夹。参见 https://stackoverflow.com/a/5293771/4284706 , https://stackoverflow.com/a/5436182/4284706如果您的设备已获得 root 权限,请获取答案。

关于android - 如何使用存储访问框架访问 "/"(根)目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40419605/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com