1

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?

Shridutt Kothari
  • 7,326
  • 3
  • 41
  • 61
  • You are asking too much. You cannot even get access to the root of primary storage as you always have to indicate a subdirectory like Environment.DIRECTORY_DCIM and so. You cannot even use an own directiry there. So wanting to get acccess to the whole file system is asking too much. – greenapps Nov 04 '16 at 11:53

1 Answers1

2

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.

Community
  • 1
  • 1
Rivu Chakraborty
  • 1,372
  • 2
  • 12
  • 37