Android Question [Solved] Creating sub-directory with ExternalStorage

ac9ts

Active Member
Licensed User
Longtime User
I can currently read and write to a root directory on a SDCard using the ExternalStorage class (v1.02) on Android 9. My question is, how do I create directories under the root directory?

File structure:

SDCard/
____RootDir/ << Can read and write here
________NewDir/ << How to create this level?
____________NewDir2/ << Would ultimately like to create this one as well
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

ac9ts

Active Member
Licensed User
Longtime User
Thank you, @DonManfred

I added this to my ExternalStorage class.

B4X:
'Creates a new directory
Public Sub FindDirOrCreate(Parent As ExternalFile, Name As String) As ExternalFile
    Dim f As ExternalFile = FindFile(Parent, Name)
    If f.IsInitialized = False Then
        Return DocumentFileToExternalFile(Parent.Native.RunMethod("createDirectory", Array(Name)))
    Else
        Return f
    End If
End Sub

@Erel Maybe update the official class?
 
Upvote 0
Top