I'm trying to delete images stored in internal storage. I've come up with this so far:
File dir = getFilesDir(); File file = new File(dir, id+".jpg"); boolean deleted = file.delete();
And this is from another question, which was answered with:
File dir = getFilesDir(); File file = new File(dir, "my_filename"); boolean deleted = file.delete();
My example always returns false. I can see the file fx 2930.jpg
in DDMS in eclipse.
Choose a folder you wish to delete files from. Tap and hold each file you wish to delete, to put a check mark on it, then tap the More (three dots) icon in the top right corner. Select Delete from device from the drop-down menu. Then select Delete from device from the pop-up menu at the bottom.
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():
Open up the Settings app. Tap on General Management and tap on Reset. Select the Factory data reset option. On the final screen, confirm by tapping Reset Device and Delete All.
Android Internal storage is the storage of the private data on the device memory. By default, saving and loading files to the internal storage are private to the application and other applications will not have access to these files.
The getFilesDir()
somehow didn't work. Using a method, which returns the entire path and filename gave the desired result. Here is the code:
File file = new File(inputHandle.getImgPath(id)); boolean deleted = file.delete();
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