Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clearing app cache programmatically?

I want to write a utility where the user can select a set of installed apps and clear their data caches i.e. like the way you can do manually using the built-in Settings->Applictions settings screen with the "Clear cache" button.

How can I access how much cached data each app has and programmatically clear these caches?

like image 605
robosheep Avatar asked Jan 05 '11 15:01

robosheep


1 Answers

The answer given here is false, there are market apps which have a programmatic clear all app cache functionality. Furthermore the following is in the documentation:

public static final String CLEAR_APP_CACHE

Since: API Level 1 in android Allows an application to clear the caches of all installed applications on the device. Constant Value:

 android.permission.CLEAR_APP_CACHE

Note the "all installed applications portion", and the fact that you don't need any root access or special permissions beyond a standard user permission.

I post here because I have a requirement on a deliverable to clear all app caches every 24 hours on an in store demo phone and I'm trying to figure out how to use this properly. I know that part of the solution is getting this permission, I also know how to find all installed applications on the device, and I'm working on being able to actually delete the cache. My issue is other app caches read as containing no files (despite having content), I suspect because I don't have read access to make the list Files call.

like image 196
Tim Capes Avatar answered Oct 04 '22 22:10

Tim Capes