Abhinav
Abhinav

Reputation: 39884

Using Application class for storing persistent data in Android

I find myself using the Application class a lot to persist user data. These are application wide resources, though I cheat by storing an integer or two sometimes. Are there any drawbacks of doing this? I could not find any documentation which puts a limit on the amount of data that can be stored here.

Upvotes: 4

Views: 1241

Answers (1)

Heiko Rupp
Heiko Rupp

Reputation: 30934

Well, the documentation to Application says :

There is normally no need to subclass Application. In most situation, static singletons can provide the same functionality in a more modular way.

Also the stuff you put in there goes to the heap(*), which is size constrained (e.g. to 24 MB). If you want to store more data, you should put it in a database or on file system.

*) Technically Android's Dalvik vm may not have a heap, but other ways to store stuff in main memory.

Upvotes: 4

Related Questions