Cannot delete files transfered from computer in Android -
i'm making video downloader app , i've got no problems saving , deleting files downloaded app external storage file transfered computer cannot deleted app.
this real problem it's 1 of key features want. here's code i'm using:
public boolean deletedatafromstorage(data todelete) { //the file object deleted file f = null; log.e(tag, "deleting " + todelete.filename); // delete file storage try { // file delete f = new file(environment.getexternalstoragedirectory().getcanonicalpath() + directory + todelete.filename); } catch (ioexception e) { log.e(tag, e.tostring()); // print stack trace e.printstacktrace(); } // delete file if(f.delete()) { return true; } else { log.e(tag, "failed delete " + todelete.filename); return false; } }
as f.delete()
function doesn't throw exceptions have no idea problem is. thing can think of app doesn't have permission delete file created in windows , yet have downloaded apps app store have no problem deleting transfered files.
any appreciated.
as per comment, since f.isfile()
, f.exists()
returns false, f
not file, in other words, you're getting path wrong.
print logs f.getabsolutepath()
, check is, , should easy fix.
Comments
Post a Comment