gpt4 book ai didi

android - 使用 Application 类在 Android 中存储持久数据

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:16:01 26 4
gpt4 key购买 nike

我发现自己经常使用 Application 类来保存用户数据。这些是应用程序范围的资源,尽管我有时会通过存储一两个整数来作弊。这样做有什么缺点吗?我找不到任何文档来限制可存储在此处的数据量。

最佳答案

嗯,documentation to Application说:

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)。如果你想存储更多的数据,你应该把它放在数据库或文件系统上。

*) 从技术上讲,Android 的 Dalvik 虚拟机可能没有堆,但有其他方法可以将内容存储在主内存中。

关于android - 使用 Application 类在 Android 中存储持久数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4871509/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com