【问题标题】:Phonegap: How to use sqlite in windows phone 8Phonegap:如何在 Windows Phone 8 中使用 sqlite
【发布时间】:2015-10-14 19:40:38
【问题描述】:

我正在将我为 android 编写的 Phonegap 应用程序移植到 Windows Phone 8 中,但我无法让 sqlite 工作。我知道 phonegap 本身还不支持 sqlite,但似乎有一个插件可以工作:

https://github.com/marcucio/Cordova-WP-SqlitePlugin

但是,我真的很难让它发挥作用。我在我的插件文件夹中包含了一些 .cs 文件,但无济于事。有人对我应该如何实际使用这个插件有任何想法吗?

谢谢!

【问题讨论】:

    标签: windows sqlite cordova phonegap-plugins


    【解决方案1】:

    您是否尝试过使用 http://developer.nokia.com/Community/Wiki/How_to_use_SQLite_in_Windows_Phone ?我还在安装和设置阶段,但希望对您有所帮助。

    【讨论】:

      【解决方案2】:

      我的插件可以在 phonegap 2.6 和 2.7 中使用。我最近尝试使用 3.0 没有成功。

      除了 .cs 文件之外,您还必须添加 Community.CsharpSqlite.WinPhone.dll 作为参考(它包含在插件包中) - 当然还要将插件添加到您的 config.xml。

      记得将 SQLitePlugin.js 复制到你的 www 文件夹并在你的 index.html 中添加一个引用脚本标签

      【讨论】:

        【解决方案3】:

        您可能想使用它:https://github.com/litehelpers/Cordova-sqlite-storage 它大部分时间都可以工作...您可以使用 CLI 以这种方式安装它:

        cordova plugin add cordova-sqlite-storage
        

        (最新版本)

         cordova plugin add https://github.com/litehelpers/Cordova-sqlite-storage
        

        (0.7.8)

        【讨论】:

          【解决方案4】:

          我建议使用 Microsoft 创建的 SQLite 插件。根据我的经验,我发现它非常可靠且快速。 https://github.com/msopentech/cordova-plugin-websql/

          cordova 插件添加cordova-plugin-websql

          据我所知,您只需对代码进行两项更改:

          1. 等待 Cordova 的 deviceready 事件,与 window.onload 相对,然后再尝试对数据库执行任何操作(我猜您可能正在这样做虽然已经)。
          2. 确保您没有在数据库对象上使用 readTransaction 方法,因为插件尚未实现该方法。但是,这不是问题,因为您可以使用 transaction 代替。前者在某些情况下会更安全一些,因为它可以确保数据不会被查询意外更改(即,它将阻止 SQL 注入攻击能够更改数据)。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2016-07-23
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多