Vi. Vi. - 22 days ago 7
Android Question

Android 4.0.3, window.openDatabase doesn't work

I'm working on a mobile app, for that I use html5/js with Phonegap.
I store some data in a local database with window.openDatabase(...).

That's work fine with Android 2.x But when I try with Android 4.0.3, I catch the following error :

D/CordovaLog(698): Uncaught TypeError: Object [object DOMWindow] has no method 'openDatabase'


My code is :

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);


Do you have an idea where that come from and how I can resolve it ? Thanks in advance.

Kind regards,
Vi.

Answer

According to http://androidforums.com/application-development/103644-why-doesnt-work-javascript-opendatabase-android.html, Android has had iffy support for window.OpenDatabase() method since the start. You may want to see this StackOverflow thread: Android 4.0.1 breaks WebView HTML 5 local storage?