开发者

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 t开发者_运维技巧here 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜