public static void trimCache(Context context) {
try {
File dir = context.getCacheDir();
if (dir != null && dir.isDirectory()) {
deleteDir(dir);
}
} catch (Exception e) {
// TODO: handle exception
}
}
public static boolean deleteDir(File dir) {
if (dir!=null && dir.isDirectory()) {
String[] children = dir.list();
for (int i = 0; i < children.length; i++) {
boolean success = deleteDir(new File(dir, children[i]));
if (!success) {
return false;
}
}
}
// The directory is now empty so delete it
return dir.delete();
}
On Wed, Aug 5, 2009 at 3:46 PM, for android <[email protected]> wrote:
> Thanks!
>
>
> On Tue, Aug 4, 2009 at 11:04 AM, Dianne Hackborn <[email protected]>wrote:
>
>> On Mon, Aug 3, 2009 at 12:20 AM, for android <[email protected]>wrote:
>>
>>> i was not talking about the files which my app writes on the local file
>>> system.
>>>
>>> I was talking about the "Clear Cache" button in here "Settings --> Apps
>>> --> Manage Apps --> "My App" --> Clear Cach"
>>
>>
>> What that button does is remove all of the files YOUR application has put
>> into the cache directory. Your code looks okay, though you should probably
>> make it recursive to take care of sub-directories.
>>
>> --
>> Dianne Hackborn
>> Android framework engineer
>> [email protected]
>>
>> Note: please don't send private questions to me, as I don't have time to
>> provide private support, and so won't reply to such e-mails. All such
>> questions should be posted on public forums, where I and others can see and
>> answer them.
>>
>>
>> >>
>>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---