Reputation: 4475
How can I delete a file from an Android application? Can I do it the same way I would for deleting a file in Java?
Upvotes: 3
Views: 11268
Reputation: 1443
File file = new File(selectedFilePath);
boolean deleted = file.delete();
and set this permission
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
in AndroidManifest.xml
file
Upvotes: 3
Reputation: 10469
The Android Developer Homepage has a really good Dev Guide section.
Answer to your question:
Files can be deleted using: File.delete()
method. (I found that by searching for "file delete" on the page above!)
But of course, there's much more to that: you need to understand how Android stores files and which files your application is allowed to modify! (basically only its own files, all the others are not accessible)
Upvotes: 2