本地存储数据
在我的应用程序中,我从数据库检索数据并在其中显示。在 db 中,某些表包含 1000 多条记录。现在我的要求是即使没有网络连接也显示这些数据,所以我计划将表存储在用户计算机上的 SQLite 数据库中,但有一个担心:
由于 SQLite 数据库将被包含在内 在资源文件夹中,在项目中, 所以默认情况下它会被包含 在应用程序二进制文件中。所以我想要 知道应用程序什么时候会 所有这些数据都将被启动 在内存上?如果是的话我觉得这个可以 导致一些问题,所以在这种情况下 - 是 有任何替代解决方案 在本地存储数据?
谢谢,
米拉杰
In my application I am retrieving data from database and showing in it. In db some of the tables contain 1000+ records. Now my requirement is to show this data even if there is no net connection, so I am planning to store the tables in SQLite db at user's machine, but there is a worry:
Since SQLite db will be included
within resources folder, in project,
so it will be by default contained
within application binary. So I want
to know that when the application will
be launched will all this data reside
on RAM ? If yes, then I think this can
cause some problems, so in that case- is
there any alternative solution to
store data locally?
Thanks,
Miraaj
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,它不会全部驻留在 RAM 中。应用程序启动时,应用程序包的内容(NIB 文件、图像等)不会全部自动加载到内存中。资源通常按需加载。例如,视图控制器可能会调用 initWithNibName: 来加载该视图的资源。
另外,除非数据库是应用程序的只读部分(除非升级,否则永远不会更改),否则您可能不希望将其存储在应用程序包中 - 请改用应用程序文档目录(尽管您可能会包含一个初始的应用程序包中数据库的“默认”副本)。请参阅 iOS 应用程序编程指南
No, it won't all reside in RAM. The contents of the application bundle (NIB files, images, etc.) are not all automatically loaded into memory when the app is launched. Resources are typically loaded on demand. For example, a view controller might call
initWithNibName:
to load the resources for that view.Also, unless the database is a read-only part of the application (never changes unless you upgrade), you probably don't want to store it in the app bundle -- use the application documents directory instead (although you might include an initial "default" copy of the database within the app bundle). See "A Few Important Application Directories" in the iOS Application Programming Guide