Android Question Folder remove

Ricardo Bunschoten

Active Member
Licensed User
Longtime User
I have a question

I want to remove a folder and i want this under a button.

I only find file.delete option but that is for files and not for folders ?

The folder is located in Android/data/xbmc.org.kodi/files/.kodi/

And i want to remove the folder .kodi which is not empy and has also subfolders with files.
 

Ricardo Bunschoten

Active Member
Licensed User
Longtime User
This is the exact path i use in my code dirrootexternal to acces it It's assigned as sd card memory but since it's a androidbox i am testing code on ít's solderd on the board
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can use this code to delete a folder recursively (be careful...):
B4X:
Sub DeleteFolderRecursive(Folder As String)
   For Each f As String In File.ListFiles(Folder)
     If File.IsDirectory(Folder, f) Then
       DeleteFolderRecursive (File.Combine(Folder, f))
     End If
     File.Delete(Folder, f)
   Next
End Sub
 
Upvote 0
Top