Reputation: 12838
I'm confused about the state of IndexedDB support in Chrome for Android.
The Todo list demo from HTML5 Rocks works fine in Chrome 23 on my desktop. In Chrome 18 on Android 4.0.4, it looks promising: window.webkitIndexedDB exists, I can open a database and create a store. But as soon as I try to write to the store, I get a READ_ONLY_ERR: DOM IDBDatabase Exception 9
.
Several overviews of Chrome for Android indicate that it supports IndexedDB, but I can't find any deeper discussions or documentation, or examples of people using it successfully.
Upvotes: 4
Views: 2979
Reputation: 4180
READ_ONLY_ERR: DOM IDBDatabase Exception 9
The error is saying what the problem is. You are trying to write data to the object store inside a readonly transaction. You need to open a transaction with readwrite.
db.transaction(["scope"], "readwrite");
I'm not sure what version of indexeddb is implemented on android 4, so it's possible it still uses integer values. in that case you should use the following: window.webkitIDBTransaction.READ_WRITE if the webkit version is present or window.IDBTransaction.READ_WRITE if the native version is present.
db.transaction(["scope"], window.webkitIDBTransaction.READ_WRITE);
EDIT I looked at the source code of the project and seen that it uses the "readwrite" version allready. Maybe this isn't implmented yet in the android version? I would advise you to use the second possibility I gave you.
Upvotes: 5