Android Question Deleting Wildcards from DirInternal

Setlodi

Member
Hi All

I hope you can assist me. My program allows me to save bitmap signatures in .png format in the DirInternal directory. I'm worried that as the files get saved I'm going to run out of space. Now I want to delete all the .png files when I start the app. I have added the wildcards class and I'm able to list *.png files. Now how do I delete these *.png files?

Thanks in advance...

Listing *.png files:
wcl.Initialize(Me,"wcl")
    Log(wcl.ListFiles(File.DirInternal, True, "*.png", True, True))
 

zed

Active Member
Licensed User
Something like that
B4X:
private Sub DeletePNG
    Dim myListFile As List
    myListFile.Initialize
    myListFile=File.ListFiles(File.DirInternal)
    For i=0 To myListFile-1
        Dim myFile As String
        myFile = myListFile.Get(i)
        If myFile.SubString(myFile.Length-3) = "png" Then
            File.Delete(File.DirInternal,myFile)
        End If
      Next
End Sub
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I am pretty sure this line:
B4X:
 For i=0 To myListFile-1
Should be:
B4X:
For i= myListFile.Size-1 To 0 Step -1
 
Upvote 0
Solution
Top