I’m storing my images in subdirectories under the cache directory. I have a cache cleaning task I want to run, that checks the size of the cache and deletes files if necessary (according to some rules I’ve set up). My question is, what’s the best time to run this? I was thinking in one of the Activity lifecycle methods. Any suggestions?
I’m storing my images in subdirectories under the cache directory. I have a cache
Share
As @binnyb said, OS will automatically clear the cache.
However, if what you call as cache is not the cache of OS (eg. You trying to store some data internal to application), then I suggest, do the check at onPause() or onResume() methods. I will not rely on onDestroy of a service.