I am using the below code for clear data in android application, but its not clearing all the data. When I see the app info after using this code, its show 30kb in data. I also see lots of tutorials in stackoverflow, but I am not able to clear all the data from my application.
public void clearApplicationData() {
File cache = getCacheDir();
File appDir = new File(cache.getParent());
if(appDir.exists()){
//Log.i("TAG", "check the delete data==" +" DELETED");
String[] children = appDir.list();
for(String s : children){
if(!s.equals("lib")){
deleteDir(new File(appDir, s));
//Log.i("TAG", "**************** File /data/data/APP_PACKAGE/" + s +" DELETED *******************");
}
}
}
}
public static boolean deleteDir(File dir) {
if (dir != null && dir.isDirectory()) {
String[] children = dir.list();
for (int i = 0; i < children.length; i++) {
Log.i("TAG", "check the delete data==" + children[i] +" DELETED count="+ i+" length="+children.length );
boolean success = deleteDir(new File(dir, children[i]));
if (!success) {
return false;
}
}
}
return dir.delete();
}