Android webview & localStorage
The following was missing:
settings.setDomStorageEnabled(true);
A solution that works on my Android 4.2.2, compiled with build target Android 4.4W:
WebSettings settings = webView.getSettings();
settings.setDomStorageEnabled(true);
settings.setDatabaseEnabled(true);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
File databasePath = getDatabasePath("yourDbName");
settings.setDatabasePath(databasePath.getPath());
}
setDatabasePath() method was deprecated in API level 19. I advise you to use storage locale like this:
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setDatabaseEnabled(true);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
webView.getSettings().setDatabasePath("/data/data/" + webView.getContext().getPackageName() + "/databases/");
}
I've also had problem with data being lost after application is restarted. Adding this helped:
webView.getSettings().setDatabasePath("/data/data/" + webView.getContext().getPackageName() + "/databases/");