java - How to clear cache of other applications -


i'm trying clear cache of applications installed on phone.

here code:

public void clearapplicationdata() {     file cache = getcachedir();     file parent1 = new file(cache.getparent());     file parent2 = new file(parent1.getparent());     if(parent2.exists()) {         string[] children = parent2.list();         for(string s : children){             if(!s.equals("lib")){                 deletedir(new file(parent2, s));                 log.d("tag", "file /data/data/app_package/" + s +" deleted");             }         }     } }  public static boolean deletedir(file dir) {     log.d("tag", "deleting :" + dir.getpath());     if (dir != null && dir.isdirectory()) {         string[] children = dir.list();         (int = 0; < children.length; i++) {             boolean success = deletedir(new file(dir, children[i]));             log.d("tag", "delete :" + success +" \n");             if (!success) {                 return false;             }         }     }      return dir.delete(); } 

in manifest file declared permission :

<uses-permission android:name="android.permission.clear_app_cache" /> 

but i'm getting parent2 null.

i can able delete application cache data using parent1.

any suggestions please.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -