I am creating a file to send as an attachment to an email. Now I want to delete the image after sending the email. Is there a way to delete the file?
I have tried myFile.delete();
but it didn't delete the file.
I'm using this code for Android, so the programming language is Java using the usual Android ways to access the SD card. I am deleting the file in the onActivityResult
method, when an Intent
is returned to the screen after sending an email.
You can delete a file as follow:
This worked for me.
Or, Try This:
Also you have to give permission if you are using >1.6 SDK
in
AndroidManifest.xml
fileI had a similar issue with an application running on 4.4. What I did was sort of a hack.
I renamed the files and ignored them in my application.
ie.
This works for me: (Delete image from Gallery)