从离线 Web 应用程序访问本地数据
我想编写一个仅供个人使用的 html/javascript/sql 应用程序,仅在本地运行(不用于通过互联网下载),它将与大型本地数据库(约 3MB)交互,并显示从非常大的数据库中提取的图像和文本。本地存储的资源(约2GB)。
我已经有一个用 Java 为 Android 编写的应用程序,但我有兴趣重新开发它,以便它能够在不同的平台(iOS 等)上运行(如果可能的话)。
我直接的问题是:“离线 Web 应用程序”是否可以访问预先存在的本地存储的数据库并读取本地存储的资源?到目前为止,我在网上找到的信息都谈到了缓存数据,这听起来不像是同一件事。
I would like to write an html/javascript/sql app for personal use only running locally (not for downloading over the internet) which would interact with a large local database (about 3MB) and display images and text drawn from a very large pool of resources stored locally (about 2GB).
I already have such an app written in Java for Android, but am interested in re-developing it so that it would be capable of being run on different platforms (iOS, etc),if possible.
My immediate question is: is it possible for an "offline web application" to access a pre-existing locally stored database and to read locally stored resources? Information that I have found so far on the web talks about cached data which doesn't sound like the same thing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信您可以简单地开发一个可在您的设备(无论是 PC、移动设备还是其他设备)上本地运行的 HTML 文件。
然后,您可以利用 HTML5 WebDatabases 来满足您的数据库需求 - 这应该可以在任何现代浏览器中运行并在客户端运行。
关于您的照片,我会将它们存储在您的 HTML 文件的子文件夹中。这样,您可以使用常规图像标签在网络浏览器中显示它们,例如:
要从 SQLite 数据库预填充或转换,您可以查看以下示例代码:https://github.com/atkinson/phonegap-prepopulate-db
它利用 SQLite 数据库的转储和 HTML5 的 FileReader迭代数据并将其插入基于浏览器的 WebDatabases 或 Web SQL 数据库中。
I believe you can simply develop a HTML file that will run locally on your device (be it a PC, mobile, or whatever).
You could then take advantage of the HTML5 WebDatabases for your database needs - this should work in any modern browser and runs client-side.
Regarding your photos, I would store them in a subfolder of your HTML file. This way, you can show them within your webbrowser using regular image tags like:
To pre-populate, or transition, from a SQLite database you can take a look at this sample code: https://github.com/atkinson/phonegap-prepopulate-db
It utilizes a dump of the SQLite database and the FileReader of HTML5 to iterate over the data and insert it into the browser-based WebDatabases or Web SQL database.