Android Question Access all files in a selected DirRootExternal folder (SOLVED!)

Cadenzo

Active Member
Licensed User
Longtime User
I tested TextEditor - Save and load external files and I also got the fact that
It is no longer possible to directly access File.DirRootExternal. The best way is to use ContentChooser.
So what would be the best way, to show pics and play audio in just one folder of DirRootExternal, which is selected before? This folder-path is always the same, so should be saved once, if selected for next app start. I need no write access, only reading. Is this still possible?

For now it works only with files, that are selected with ContentChooser just before. For all others I get java.lang.SecurityException: Permission Denial: reading com.android.fileexplorer.provider.FileExplorerFileProvider uri content://com.mi.android.globalFileexplorer.myprovider/root_files/storage/4AE5-2027/_SD_Audio/...

The background is, that I want to allow the user to play audio, that he pasted before to a special folder.

Any suggestions?
 
Last edited:

Cadenzo

Active Member
Licensed User
Longtime User
Okay, I solved it. Creating my directory "TalkingToy/Dir1". You can find it on "...\Android\data...\files\TalkingToy\Dir1", copy your files to the given folder and then access it in the app.

B4X:
    Dim rp As RuntimePermissions
    
    Dim sTest As String = rp.GetSafeDirDefaultExternal("TalkingToy")
    Log(sTest)
    'File.MakeDir(sTest, "Dir1")
    Dim sDir As String = sTest & "/Dir1"
    Dim li As List = File.ListFiles(sDir)
    Dim sFile As String = li.Get(0)
    
    MP.Load(sDir, sFile)
    MP.Play
 
Upvote 0
Top