Using the Application class to store persistent data in Android

I often use the Application class to save user data. These are extensive application resources, although I cheat, sometimes storing an integer or two. Are there any flaws in this? I could not find documentation that limits the amount of data that can be stored here.

+4
source share
1 answer

Well, the documentation for the Appendix says:

As a rule, there is no need to subclass Application. In most cases, static singletones can function in a more modular way.

Also, the material that you put there falls into the heap (*), which is limited in size (for example, up to 24 MB). If you want to store more data, you must put it in a database or file system.

*) Technically, Android Dalvik vm may not have heaps, and other ways to store files in main memory.

+4
source

Source: https://habr.com/ru/post/1338053/


All Articles