Reputation: 1129
I have a file with this path:
file:/mnt/sdcard/Android/data/myapp/files/Pictures/IMG_20140108_160223.jpg
When I try this code:
File f = new File(path);
f.delete();
The file is not deleted. How can I do?
Upvotes: 0
Views: 258
Reputation: 607
I've found a similar question here:
How to delete a file from SD card?
The file:
prefix seems unnecessary.
try/mnt/sdcard/Android/data/myapp/files/Pictures/IMG_20140108_160223.jpg
Also you have to give permission if you are using >1.6 SDK
uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
in AndroidManifest.xml
file
Upvotes: 1
Reputation: 25401
You may need to use
file.getCanonicalFile().delete();
or even (assumming this is a context)
this.deleteFile("string");
More Infos here to delete file with context object
You may also delete your file:/
at the beginning of your File object creation.
Upvotes: 1