This took me a full day to figure out, so I'd like to give full documentation about how to solve this problem on Android 4.2 and 4.3.
You can use Web SQL from a file://
URL in WebView. The Cordova folks managed to do it. There are just three things you must do:
1) Call setDatabaseEnabled()
(duh):
webView.getSettings().setDatabaseEnabled(true);
2) Set the database file path. Yes, this is deprecated in Android 4.4, but it is required if you want to avoid the DOM Exception 18 in pre-Kitkat:
String databasePath = getContext().getApplicationContext().getDir(
"database", Context.MODE_PRIVATE).getPath();
webView.getSettings().setDatabasePath(databasePath);
3) Set the onExceededDatabaseQuota
handler. Yes, it's deprecated in Android 4.4, blah blah blah.
webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onExceededDatabaseQuota(String url, String databaseIdentifier, long currentQuota, long estimatedSize,
long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater) {
quotaUpdater.updateQuota(estimatedSize * 2);
}
});
If you skip any one of these 3 steps, then you will get the DOM Exception 18 error and Web SQL will not work. You've been warned.