Android Question Strange issue when deleting files on android 5

victormedranop

Well-Known Member
Licensed User
Longtime User
Hi, I havind some problems with delete files fon external storage.
internal works fine.

I try

B4X:
Log(File.Delete(File.DirDefaultExternal,tmpFileName))

I see my file but said false.

here is my code
B4X:
public Sub delete_files
 Dim lstFilter As List
 lstFilter.Initialize
 lstFilter.AddAll(Array As String(".mp4",".mp3",".jpg", ".gif", ".png", ".jpeg" ))
 Dim fileList As List
fileList.Initialize
fileList = File.listfiles(File.DirRootExternal)
Dim tmpFileName As String
tmpFileName=""
For i = 0 To fileList.Size - 1
tmpFileName =fileList.Get(i)
For f = 0 To lstFilter.Size - 1
If tmpFileName.EndsWith(lstFilter.Get(f)) Then
Log("deleting FILENAME : " & tmpFileName)
Try
If (File.Exists(File.DirRootExternal,tmpFileName)) = True Then
Log(File.Delete(File.DirDefaultExternal,tmpFileName))
End If
Catch
Log(LastException)
End Try
Else
tmpFileName=""
End If
Next
Next
End Sub
 
Top