I have used the Android internal storage to save a file for my application (using openFileOutput
) but I would like to delete that file, is it possible and how?
Clear cache memory Most of the memory of the phone goes to the cache, so first, clear it. Go to settings and go to storage. Here you will see the cache. Clear it.
But in most cases, you can see the internal storage of an Android phone: Navigate to My Files to view internal storage as well as SD card and Network storage. Here, tap Internal Storage to see your files and folders. Tap the DCIM folder to view your photos.
File dir = getFilesDir(); File file = new File(dir, "my_filename"); boolean deleted = file.delete();
I know this is a bit of an oldie, but the docs say to use:
deleteFile("filename");
rather than:
File.delete();
Which if you are already using:
getFilesDir();
kind of makes sense.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With