Android浏览器是否支持索引数据库?

时间:2013-09-30 20:15:39

标签: android html5 cordova indexeddb

我用phonegap写了一个android应用程序。我想使用indexedDB,但我总是有一个例外。 NOT_FOUND_ERR:DOM IDBDatabase异常3:264

当我初始化indexedDB时,我没有收到错误:

//todo csinálni kell inicializált eventet

// In the following line, you should include the prefixes of implementations you want to test.
window.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
// DON'T use "var indexedDB = ..." if you're not in a function.
// Moreover, you may need references to some window.IDB* objects:
window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || window.msIDBTransaction;
window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange || window.msIDBKeyRange;
// (Mozilla has never prefixed these objects, so we don't need window.mozIDB*)

if (!window.indexedDB) {
    window.alert("Your browser doesn't support a stable version of IndexedDB. Such and such feature will not be available.");
}

当我记录indexedDB时,我得到[object IDBDatabase]

我在此行收到错误:var trans = db.transaction([index], "readwrite");

我的代码适用于PC上的桌面浏览器,但它无法在平板电脑上运行。我已经在我的PC上测试了Chrome和Firefox浏览器。

如何解决问题

1 个答案:

答案 0 :(得分:0)

从我的测试来看,Android 4.1(及以上版本)在Web客户端和股票浏览器中都有IndexedDB。虽然实施是错误的,不完整的和过时的。

而不是" readwrite",使用旧样式window.webkitIDBTransaction.READ_WRITE