简体   繁体   中英

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?

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.

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

You can't get access to root folder if the device is not rooted. See https://stackoverflow.com/a/5293771/4284706 , https://stackoverflow.com/a/5436182/4284706 for answers if your device is rooted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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