Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start path when using Intent.ACTION_OPEN_DOCUMENT_TREE

Is it possible to specify an "start path" when using Intent.ACTION_OPEN_DOCUMENT_TREE ?

When I use it like this:

 Intent chooseFolderIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
 startActivityForResult(Intent.createChooser(chooseFolderIntent, getString(R.string.save_to_directory)), CHOOSE_FOLDER_CODE);

It starts displaying all the folders from the root of the phone. But I would like it to start displaying a certain path (eg. DCIM folder)

Is there any extras I can use to specify this?

like image 898
sports Avatar asked Oct 16 '18 18:10

sports


1 Answers

On API 26+, you can use DocumentsContract.EXTRA_INITIAL_URI to set the initial directory for the ACTION_OPEN_DOCUMENT_TREE Intent. Note that the URI must be one retrieved from the Storage Access Framework APIs (i.e., it must be a document tree URI).

There's no way to do this pre-API 26.

like image 67
ianhanniballake Avatar answered Oct 18 '22 20:10

ianhanniballake