Reputation: 729
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
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