How to use android directory chooser from a specified directory path
Asked Answered
A

0

6

I am new to android and learning it, what I want is to choose folder/directory from a specified path like in my case path will be sd-card/DMM/DT, I want that directory chooser start from this folder not from generic location.

I am using this code already

 Intent i = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
 i.addCategory(Intent.CATEGORY_DEFAULT);
 startActivityForResult(Intent.createChooser(i, "Choose directory"), 9999);

and for result method, I am using this

public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch(requestCode) {
    case 9999:
        Log.i("Test", "Result URI " + data.getData());
        break;
     }
} 

The above code works fine but not the way I want,

I know there are many libraries already for directory and file chooser but I am not getting my required from them.

I also tried to play with some method like Intent.setData and Intent.setDataAndType but don't know how to point the directory chooser from a specific location.

Any help would be appreciated

Also I tried the following links

https://github.com/passy/Android-DirectoryChooser/tree/master/sample

Android: Directory and file chooser android library

https://android-arsenal.com/details/1/160

and many more but couldn't get any help.

Amalgamate answered 7/8, 2018 at 17:5 Comment(1)

© 2022 - 2024 — McMap. All rights reserved.