How do I delete a file or folder on the internal storage in android with Delphi for android
2 Answers
You should use the TFile
and TDirectory
classes in the System.IOUtils
unit.
For example:
TDirectory.Delete(<YOUR DIR PATH>);
or
TFile.Delete(<YOUR FILE PATH>);
Look in Embarcadero's documentation to get the right path of your files and folders on the various platforms:
Standard RTL Path Functions across the Supported Target Platforms

- 555,201
- 31
- 458
- 770

- 86
- 1
- 1
Referred from :
https://stackoverflow.com/a/27047502/5193608 https://stackoverflow.com/a/3554949/5193608
Main Part from both links:
You should always delete files that you no longer need. The most straightforward way to delete a file is to have the opened file reference call delete() on itself.
myFile.delete();
If the file is saved on internal storage, you can also ask the Context to locate and delete a file by calling deleteFile():
myContext.deleteFile(fileName);
Note: When the user uninstalls your app, the Android system deletes the following: All files you saved on internal storage All files you saved on external storage using getExternalFilesDir(). However, you should manually delete all cached files created with getCacheDir() on a regular basis and also regularly delete other files you no longer need.
Source : http://developer.android.com/training/basics/data-storage/files.html
Directly you can do is :
File dir = getFilesDir();
File file = new File(dir, "my_filename");
boolean deleted = file.delete();
Hope,it helps!

- 1
- 1

- 773
- 7
- 31
-
OP uses Delphi, not Java :) – kami Feb 24 '16 at 11:32