Is there anyway to clear the cache on my app when I exit?
I made webview app but it eat to much data and stored to cache. I wanted to clear it when I close the app.
I am using Java in Android studio
You can clear the cache when the app is closed. For knowing when the app is closed from the recents list(destroyed), you can do this:
Add this code in your activity
@Override
public void onDestroy(){
getCacheDir().delete();
}
This will clear the cache when the activity Is closed
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.