Open Specific Directory Using Storage Access Framework
Asked Answered
I

1

13

I'm currently able to obtain a file URI by opening the Lollipop file picker using the code below:

            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_OPEN_DOCUMENT_TREE);
            startActivity(intent);

The file picker opens either at the root of Internal Storage or the last directory that I opened. How can I make the file picker show the contents of a specific directory? For example, I might want the file picker to show the contents of the Download folder after launching like in the picture below.

opened subdirectory

Indign answered 8/5, 2015 at 3:27 Comment(2)
you have found a solution?Fairfax
@VadimStar not yet :(. I haven't been actively developing for Android recently, though.Indign
B
-2

Use the Environment class which has methods like getExternalStorageDirectory() or getDataDirectory() https://developer.android.com/reference/android/os/Environment.html.

If the images are stored in a variable, grab them from that path:

private static final String fileName = Environment
            .getExternalStorageDirectory().getAbsolutePath()
            + "/pathToFile.jpg";
Beograd answered 11/1, 2018 at 7:31 Comment(1)
getExternalStorageDirectory() has been deprecated.Send

© 2022 - 2024 — McMap. All rights reserved.