是否可以在 Palm Pre 上预加载 Sqlite DB?
我有一个 Palm Pre 应用程序,它有一个很大的数据库。我想将数据库直接传输到手机,而不是让应用程序创建数据库。
我尝试的是使用一个简单的Python脚本在PC上创建一个sqlite文件,然后让应用程序在媒体/内部文件夹中创建一个空的扩展数据库,然后将PC文件复制到手机上创建的文件上。但是,在尝试读取文件时出现错误:“数据库磁盘映像格式错误”。
有没有人成功地做过这样的事情?
编辑:现在我原来的想法实际上是不可能的,我的问题变成:用大量数据初始化应用程序数据库而不重复它的最佳方法是什么(现在我有一个包含信息和第一次运行应用程序时,它会创建并填充数据库)。使用混合应用程序的解决方案现在对我来说太多了,我需要一个简单而快速的解决方案。
另一种选择可能是连接到“网络服务”并将数据下载到应用程序。
I have a Palm Pre app that has a large(ish) database. I would like to transfer the database directly to the phone rather than having the app create the database.
What I tried is to create a sqlite file on the PC using a simple python script, then have the app create an empty extended db in the media/internal folders, then copy the PC file over the one created on the phone. However I get an error when trying to read the file: "database disk image is malformed".
Has anyone succeeded in doing something like this?
Edit: Now that my original idea is actually not possible my question becomes: what is the best way to initialize an application DB with a lot of data without duplicating it (now I have an array with info and the first time the app is run it creates and fills the database). The solution to use a hybrid application is too much for me now, I need a simple and quick solution.
The alternative would probably be to connect to a 'web service' and download the data to the application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法直接从 JavaScript 代码访问预加载的 SQLite 数据库——虽然 WebKit 在内部使用 SQLite,但它需要将数据库与其自己的数据结构相关联并管理一些约束。
您可以编写一个混合应用程序,其中 C/C++ 代码仅充当用于访问所包含数据文件的服务器。您可以在混合应用程序中使用 SQLite 的静态版本来访问该数据并将其通过 IPC 系统发送到 JS。该模型类似于设备上的 Quickfoffice 如何使用混合来解析 MS Word 文档并将其表示形式发送到 JS 应用程序,该应用程序使用 WebKit 的渲染引擎显示它们。
You can't access a preloaded SQLite database directly from your JavaScript code -- while WebKit is using SQLite internally, it needs to associate the database with its own data structures and manage some constraints.
You could write a hybrid application where your C/C++ code just acted as a server for accessing the included data file. You can use that static version of SQLite in your hybrid app to get access to that data and send it over the IPC system to JS. That model is similar to how Quickfoffice on the device uses a hybrid to parse MS Word documents and send their representation to their JS app that shows them using WebKit's rendering engine.
让应用程序创建一个基本 sqlite 文件,然后将其下载到桌面以添加批量数据是否可行?您可能应该先关闭该应用程序,然后再将其发送回手机。如果它是像日历这样的内置应用程序,您可能会遇到问题,因为后台进程可能仍在访问数据库。也许上传后重启就能解决。
Is it feasible to let the app create a base sqlite file, then download that to your desktop in order to add the bulk data? You should probably close the app before sending it back to the phone. If it's a built-in app like calendar, you might have issues because a background process might still be accessing the db. Maybe a reboot after uploading will solve it.