how to delete the contents in getExternalFilesDir(null) android -


i have saved files using command:

file file = new file(cont.getexternalfilesdir(null), filename); 

how can delete of files have saved? need clear content of cont.getexternalfilesdir(null) directory. thanks

if want delete file can told perroloco, if need delete content think oo approach better :)

first build method delete files inside directory recursively

private void deleteallcontent(file file,string... filename) {     if (file.isdirectory())         (file child : file.listfiles())             deleteallcontent(child);     if(filename==null)         file.delete();     else         for(string fn:filename)             if(file.getname().equals(filename))                 file.delete();  } 

then can call new method external files dir.

deleteallcontent(cont.getexternalfilesdir(null)); 

or

deleteallcontent(cont.getexternalfilesdir(null),"myfile1","myfile2","etc"); 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -