使用应用程序类存储在Android的持久性数据 [英] 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.
推荐答案
那么,的文档,应用程序说:
有通常没有必要继承
应用。在大多数情况下,静态
单身可以提供相同的
功能更模块化的方式。
There is normally no need to subclass Application. In most situation, static singletons can provide the same functionality in a more modular way.
另外你把东西那里进到堆(*),它是尺寸约束(例如为24 MB)。如果你想存储更多的数据,你应该把它放在一个数据库或文件系统上。
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.
*)技术上Android的Dalvik虚拟机可能没有堆,但是其他的方式来存储的东西,在主内存中。
*) Technically Android's Dalvik vm may not have a heap, but other ways to store stuff in main memory.
这篇关于使用应用程序类存储在Android的持久性数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!