Dele files in File.DirInternal

magarcan

Active Member
Licensed User
Longtime User
Hi! I'm developing an app that save some files in File.DirInternal. How can I delete all my saved files?

Thanks!!
 

magarcan

Active Member
Licensed User
Longtime User
Works nice thanks.
 
Upvote 0

cbal03

Member
Licensed User
Longtime User
I also had a need to remove these files. But I also wanted to view them with traditional viewing tools like a file manager (File Manager HD) and a database utility (SQLite Editor).
Copying them to a less secure directory works fine for these abilities. Thank you NJDude for the pointers in the right direction.

B4X:
Sub copy_protected_files
   Dim FilesToCopy As List
   
   FilesToCopy.Initialize
   FilesToCopy.AddAll(File.ListFiles(File.DirInternal))
   
   For I = 0 To FilesToCopy.Size -1
    File.Copy(File.DirInternal, FilesToCopy.Get(I), File.DirDefaultExternal, FilesToCopy.Get(I))
   Next
   ToastMessageShow("Databases Copied", True)
End Sub
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
like this you can delete files that contains a specific string:

B4X:
Sub delusercomplete(deluser As String)

    Dim MyFile As String
    Dim MyList As List
    MyList.initialize
    MyList = File.ListFiles(File.DirInternal)
    For i = MyList.Size - 1 To 0 Step -1
        MyFile = MyList.get(i)
        If MyFile.Contains(deluser) Then
            File.Delete(File.DirInternal,  MyFile)
            Log("Deleted File: " & MyFile)
        End If
    Next

End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…