在iPhone上模拟写入SQLite3

发布于 2024-07-29 13:35:52 字数 193 浏览 3 评论 0原文

我有一个在模拟器中运行的应用程序。 我从 sqlite3 数据源读取和写入。 但是,如果我重新启动应用程序,那么我之前写入数据库的所有数据都会丢失。 数据始终处于其原始状态。

现在,当我开发这个应用程序时,我想我在某处读到数据无法通过 iPhone 模拟器保存。

有人能证实或否认这一点吗?

谢谢!

I have an app that is running in the simulator. I read and write from a sqlite3 data source. However, if i restart the app, then all datg that i had previously wrote to the db is lost.
The data is always in its original state.

Now back when i was developing this app i thought i read somewhere that data can not be persisted via iphone simulator.

Can anybody confirm or deny this?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

油饼 2024-08-05 13:35:52

您需要将数据库文件放在可写的位置,例如在 Documents 文件夹中。 所有捆绑文件都是只读文件。

如果您要随应用程序分发初始数据库,则需要将其复制到 Documents(或其他文件夹)并使用该副本。

您还需要确保在应用程序关闭时关闭数据库连接(即您收到 applicationWillTerminate 消息)。

You need to place your db file in a writable place, e.g. in the Documents folder. All the bundle files are read-only files.

If you are distributing an initial database with the app, you will need to copy it to Documents (or another folder) and use the copy.

You also need to ensure that you close the database connection in your application is closing (i.e. you receive a applicationWillTerminate message).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文