0

I have to clear cache of all installed applications from my application.I have tried to clear the cache on click of button.But on click of button it throws nullpointerexception.In android market so many applications are there to clear the cache.

But i have to do manually in my program.

This is my code

      Button button=(Button) findViewById(R.id.button1);

    button.setOnClickListener(this);

   @Override
public void onClick(View v) {

           File  f=new File("/data/data");
    File   ff[]=f.listFiles();

    for(int i = 0; i < ff.length; i++){
        ff[i].delete();
    }


}

How can i do this ?

Sulthan Allaudeen
  • 11,330
  • 12
  • 48
  • 63
Sairam
  • 31
  • 1
  • 3

1 Answers1

0

You can't unless rooted. Each app's private directory can be read only by that app itself. This is for security- so each app can have data that no other app can manipulate.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127