private void clearApplicationCache(java.io.File dir){
if(dir==null)
dir=getCacheDir();
else{}
if(dir==null)
return;
else{}
java.io.File[] children =dir.listFiles();
try{
for(int i=0;children.length;i++)
if(children[i].isDirectory())
clearApplicationCache(children[i]);
else childen[i].delete();
}
catch(Exception e){}
}
public void onDestroy(){
super.onDestroy();
clearApplicationCache(null);
}
|
public void clearApllicationCache(){
File dir=new File("/src/ss");
if(dir !=null && dir.isDrectory()){
try{
ArrayList<File> stack=new ArrayList<File>();
File[] children =dir.listFiles();
for(File child : children){
stack.add(child);
}
while(stack.size() > 0){
File f=stack.get(stack.size() - 1);
if(f.isDirectory() == true){
boolean empty = f.delete();
if(empty == false){
File[] files = f.listFiles();
if(files.length !=0){
for(File tmp : files){
stack.add(tmp);
}
}
}else(stack.remove(stack.size() -1);
}
}else{
f.delete();
stack.remove(stack.size() -1 );
}
}
}catch(exception e){
Log.e("cntrl->", "Failed to clean the cache" + e.getMessage());
return;
}
} |