I have a web app that runs on earlier versions of Android but seems to have problems when run on Android 4.0.3 (HTC 1x) Namely the openDatabase javascript function is "undefined", is this api supported?
-
1What does your `openDatabase()` call look like? Some posts I'm finding describe the need to add a fourth parameter on ICS. – Cᴏʀʏ May 16 '12 at 21:54
-
I can confirm that WebSQL works on 4.0.2 Verizon Galaxy Nexus. – Will May 29 '12 at 20:12
-
When I run the Javascript below I get the exception "openDatabase is not defined". Any suggestions? var dbVersion = '0.1'; var displayName = 'Animals'; var maxSize = 65533; var dataBase; alert("calling openDatabase"); try { dataBase = openDatabase(dbName, dbVersion, displayName, maxSize); } catch (err) { alert(err.message); } – Terry Canning Jun 07 '12 at 15:45
2 Answers
I think the answer to this question is "it depends on the device." I've been trying to solve the issue for a web app that's working fine on iOS and some Android devices, but not others, and we've seen issues with some 4.0.3, some 4.0.4, and some 2.3.x (so far, the one 2.2.x device we've tried worked fine). I've spent weeks trying to come up with a client-side solution, but I think there may be none. Strangely, manipulating the db version seems to change things somewhat in some devices, even if you aren't versioning the db, but it doesn't solve the problem. Neither does changing maxSize.
WebSQL is deprecated and who knows if it will continue to be supported across devices, so I think the best strategy is to use some kind of abstraction (like Lawnchair) or for now, go with localstorage/sessionstorage or, in the future indexedDB.

- 143
- 1
- 10
Yes, of course, I use it on Android 2.2 so I think 4.0.x is also compatible with it...
Can you post your Javascript code ?
var db = openDatabase(shortName, version, displayName, maxSize);

- 7,269
- 1
- 29
- 54
-
Javascript is..var dbVersion = '0.1'; var displayName = 'Animals'; var maxSize = 65533; var dataBase; alert("calling openDatabase"); try { dataBase = openDatabase(dbName, dbVersion, displayName, maxSize); } catch (err) { alert(err.message); } – Terry Canning Jun 07 '12 at 15:48
-
Actually when I upgrade my phone software the openDatabase exception changed to "SECURITY_ERR:DOM Exception 18". Any ideas? – Terry Canning Jun 08 '12 at 09:18
-
Oddly enough when I cleared my cache, restarted the device I am not just getting the old error "openDatabase" is not defined. So am now at a complete loss! – Terry Canning Jun 08 '12 at 10:17