javascript - Android 4.0.3,window.openDatabase 不工作

标签 javascript android html cordova opendatabase

我正在开发一个移动应用程序,为此我将 html5/js 与 Phonegap 结合使用。 我使用 window.openDatabase(...) 将一些数据存储在本地数据库中。

这在 Android 2.x 上工作正常但是当我尝试使用 Android 4.0.3 时,我发现了以下错误: D/CordovaLog(698): Uncaught TypeError: Object [object DOMWindow] 没有方法 'openDatabase'

我的代码是:

if (!window.openDatabase)
    alert("Error: can't open local database");
if (!localStorage)
    alert("Error: localstorage not usable");

var db = window.openDatabase("Database", "1.0", "DatabaseName", 200000);

您知道它从何而来以及我该如何解决它吗?提前致谢。

亲切的问候, 六。

最佳答案

根据 http://androidforums.com/application-development/103644-why-doesnt-work-javascript-opendatabase-android.html , Android 从一开始就对 window.OpenDatabase() 方法有不确定的支持。您可能希望查看此 StackOverflow 线程:Android 4.0.1 breaks WebView HTML 5 local storage?

关于javascript - Android 4.0.3,window.openDatabase 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12076356/

相关文章:

html - 使用 CSS 更智能地居中 div

css - 如何使子 div 元素受 div css 规则影响?

android - 当我们上下滚动recyclerView时隐藏和显示 View 组

javascript - ReactJS + Redux : How to use Mozilla File API to select local image and upload it to web?

javascript - 为什么 css transition 会延迟工作

javascript - Kineticjs - 修复了旋转形状的填充图案

java - 在 Struts 2 中使用 ModelDriven 访问 POJO 属性?

javascript - window.screen.width 和 window.screen.height 在 iPad 3 上不起作用

android - 获取安卓付费应用购买日期

android - "Toast"通过 TimerTask 发送消息