3

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.

user1178988
  • 729
  • 1
  • 6
  • 5

1 Answers1

2

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

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Yugandhar Babu
  • 10,311
  • 9
  • 42
  • 67
  • 1
    Thanks for answering. I already have that permission in the manifest. When I test for file existence, I get true even though the file exists and I'm using the same file path when I created the file. – user1178988 Jan 31 '12 at 15:41