user1178988
user1178988

Reputation: 729

Android File.delete not working

Im trying to delete an image file after I saved it to SD card, but the delete function is not working. Any help will be appreciated. Here is my code:

// Save image to SD card
String path = Environment.getExternalStorageDirectory().toString(); 
File file = new File(path, "tmpimage" + ".jpg"); 
....
....
....
// Delete image from SD card
file.delete();

Later on I found out that I was actually deleting the file. The File.delete function actualy was working ok. I was saving the image also to the Gallery and was expecting the file.delete to remove it from Gallery. Thanks everyone for answering my question.

Upvotes: 3

Views: 3623

Answers (1)

Yugandhar Babu
Yugandhar Babu

Reputation: 10349

I think you forgot to add below permission in manifest, just check it if not.

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Upvotes: 2

Related Questions