mudit mudit - 4 years ago 148
Android Question

How to delete a file from SD card?

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

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
method, when an
is returned to the screen after sending an email.

Answer Source
File file = new File(selectedFilePath);
boolean deleted = file.delete();

where selectedFilePath is the path of the file you want to delete - for example:


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download