简体   繁体   English

如何使用存储访问框架访问“ /”(根)目录

[英]How to get access to “/” (root) directory using Storage Access framework

I am trying to get access to "/" (root) directory using Storage Access Framework on Android 7.0 and above, after looking to the Google sample on GitHub , i can see that there are only predefined directories are passed in while creating accessIntent using StorageVolume class, but how to get access to any other directory than those predefined directories? 我试图在Android 7.0及更高版本上使用Storage Access Framework访问"/" (根)目录,在GitHub上查看Google示例后,我可以看到在使用StorageVolume创建accessIntent时仅传递了预定义目录类,但是如何访问除这些预定义目录之外的任何其他目录?

Here is my code, which i tried: 这是我尝试的代码:

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

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

i am getting null as storageVolume and unable to get access to "/" directory using StorageVolume framework. 我的存储卷为null,无法使用StorageVolume框架访问“ /”目录。

How to get Scoped Directory Access to "/" directory using Storage Access Framework on Android 7.0 and above? 如何在Android 7.0及更高版本上使用Storage Access Framework"/"目录进行范围目录访问

You can't get access to root folder if the device is not rooted. 如果设备不是root用户,则无法访问root文件夹。 See https://stackoverflow.com/a/5293771/4284706 , https://stackoverflow.com/a/5436182/4284706 for answers if your device is rooted. https://stackoverflow.com/a/5293771/4284706https://stackoverflow.com/a/5436182/4284706答案,如果你的设备是植根。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM