I am trying to delete a file stored in internal memory. The file does gets deleted by using
activity.deleteFile(filename);
but only in emulator. On the actual device the method always returns false. When I try to access the file from adb shell there is permission denied being displayed. So, I guess there is permission related issue with deleting the files in internal memory.
Can someone let me know how to actually delete the file from internal memory in Android?
If you're talking about just any file in the file system... Does this not work?
if (new File("fileUrl").delete()) {
// Deleted
} else {
// Not deleted
}
Due to security constraints you can only delete files that were created by your app. You also can not delete files that are part of your app package (apk), i.e. files in /res, /assets, etc..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With