开发者

how to delete cache programmatically?

开发者 https://www.devze.com 2023-04-09 03:21 出处:网络
I want to delete the cache files in my application programmatically. How do i go about doing this in code?

I want to delete the cache files in my application programmatically.

How do i go about doing this in code?

I want to launch a service (which i already have set up to do this).

FYI - IDK why my acceptance ra开发者_运维问答te is low. Ive accepted most or all of my answers.


I assume you're talking about the Context's cache directory?

This is one way:

File cacheDir = context.getCacheDir();

File[] files = cacheDir.listFiles();

if (files != null) {
    for (File file : files)
       file.delete();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消