[UWP] [HTML]如何在UWP(Javascript)应用程序中添加本地数据库 [英] [UWP][HTML]How to add a local Database in the UWP (Javascript) application

查看:89
本文介绍了[UWP] [HTML]如何在UWP(Javascript)应用程序中添加本地数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,¥b $ b


是否可以为UWP(Javascript)应用程序提供本地数据库。?


需要本地数据库,因为我的应用程序需要保存 离线模式下的数据(没有互联网连接)


如果可能请指导我这样做。



问候,

Ashwin

解决方案


SQLite的
为轻量级本地数据库,用于在用户设备上存储和检索数据。请在这里看一下这个类似的问题( https://social.msdn.microsoft.com/Forums/en-US/20639c1b-d0a5-421a-b89c-5c29a790696f/uwpwinjssqlite-database-in-windows-10-by-winjs?forum = wpdevelop )。
如标记答案中所述,您可以编写一个包装器来使用Windows运行时组件访问SQLite,并使用JavaScript调用该组件。请参阅这篇文章介绍如何

创建一个简单的Windows运行时组件并从JavaScript调用它
。尽管帖子中的示例代码已过时,但我认为它有助于作为指导。


如果您不想为WinJS App编写包装器,还有另一种解决方法。您可以创建

AppService服务
作为后台任务运行,它提供SQLite数据库访问,然后在您的javascript应用程序中调用应用程序服务。 AppService提供商应用程序也部署在同一设备中,因此它仍然可以在离线模式下工作。


祝你好运,


Roy


Hello,

Is it possible to have a local database for a UWP (Javascript) application.?

The local database is needed because my application will need to save the  data in offline mode(no internet connection)

If possible Please guide me the way to do it.

Regards,
Ashwin

解决方案

Hi,

SQLite is a light-weight local database for store and retrieve data on user device. Please take a look at this similar question here(https://social.msdn.microsoft.com/Forums/en-US/20639c1b-d0a5-421a-b89c-5c29a790696f/uwpwinjssqlite-database-in-windows-10-by-winjs?forum=wpdevelop). As mentioned in the marked answer, you can write a wrapper to access the SQLite using Windows Runtime Component, and call the component in JavaScript. Please refer to this article describes how to create a Simple Windows Runtime component and calling it from JavaScript. Even though the sample code in the post is outdated, I think it is helpful as a guidance.

If you don’t want to write a wrapper for WinJS App, there is another workaround. You can create an AppService run as background task, which provides SQLite database access, and then call the app service in your javascript app. The AppService provider app is also deployed in the same device so that it could still working in offline mode.

Best regards,

Roy


这篇关于[UWP] [HTML]如何在UWP(Javascript)应用程序中添加本地数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆