Android Question Setting initial folder for the Folder Picker

noeleon

Active Member
Licensed User
How can I set the initial folder when I launch the folder picker?

B4X:
Dim i As Intent
i.Initialize("android.intent.action.OPEN_DOCUMENT_TREE", "")
i.putExtra ????????
StartActivityForResult(i)

I saw a post on the internet that use the following line but it does not work in B4A
putExtra("android.provider.extra.INITIAL_URI", folderUri)
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Set UsePreviouslySelectedIfAvaiable to True and the previously selected folder will be selected automatically.
2.
I saw a post on the internet that use the following line but it does not work in B4A
B4A doesn't do anything with the intent. It is sent to the OS.
How did you create folderUri?
 
Upvote 0

noeleon

Active Member
Licensed User
How did you create folderUri?
It's the persistable uri from the Folder picker.

The problem is I also have a File picker using android.intent.action.GET_CONTENT and because they're using the same System UI/Activity the starting folder shown when it's launched is always the one last used. What I wanted was when the File Picker is launched the starting folder is the one where File Picker left off or a pre-set location. The same goes for the Folder Picker.

Anyway, I'll just make my own file/folder picker based on your sample project for the ExternalStorage class. I find using the system File Picker problematic if the user picks a file using third party file providers like TotalCMD, ZArchiver, etc., the ones on the side drawer of the file picker.
 
Upvote 0
Top