Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete a file that exists [duplicate]

Tags:

android

Possible Duplicate:
How to delete a file from SD card?

This should be simple for most people, I want to know how to delete a file in the SD card (/sdcard/folder) if it exists i.e?

like image 514
Beginner Avatar asked Feb 09 '11 13:02

Beginner


1 Answers

Try this:

File folder = Environment.getExternalStorageDirectory();
string fileName = folder.getPath() + "/folder/image1.jpg";

File myFile = new File(fileName);
if(myFile.exists())
    myFile.delete();
like image 117
Tawani Avatar answered Oct 16 '22 14:10

Tawani