Clearing app storage

My app uses banner ads and unfortunately every time the banner is loaded / displayed the storage app jumps some amount. To see how much, the app uses about 21.69 MB when first installed. During the day, this can go up to 30 MB. Most of all it is up to 51 MB. At this point, I cleared the storage.

Now if I disable ads the problem goes away. I contacted my ad network that recommended updating my SDK, which I did, but it didn't matter.

The thing is, it's quite common, I've downloaded 2 or 3 games from the Play Store and tested them by running, launching and restarting apps over and over again, and indeed the storage is increasing.

My 2 questions:

  • Is there a way (programmatically) to clear the app store (say from ondestroy)
  • If there is, is there a way to do this while keeping the shreadPrefs which I use for things like user settings, levels unlocked, etc.
+3


source to share


1 answer


Yes! Ad banners are probably stored in the app cache .

You can get the app cache path using a method Context.getCacheDir()

(as mentioned in the doc )!



So, I suggest that you clear your entire app cache directory to do what you need. Fortunately, the settings are saved in the application data directory!

0


source







All Articles