How to delete cache-folder of app?

前端 未结 5 556
刺人心
刺人心 2020-12-14 19:48

I read through the Android documentation of the cache (see Data Storage Documentation) but I didn\'t got how I can clean the whole folder.

So how can I dele

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-14 20:42

    From the documentation:

    Saving cache files

    If you'd like to cache some data, rather than store it persistently, you should use getCacheDir() to open a File that represents the internal directory where your application should save temporary cache files.

    When the device is low on internal storage space, Android may delete these cache files to recover space. However, you should not rely on the system to clean up these files for you. You should always maintain the cache files yourself and stay within a reasonable limit of space consumed, such as 1MB. When the user uninstalls your application, these files are removed.

    Create a method to recurse through the folder and delete them, if that's what you want to do.

提交回复
热议问题