Estoy tratando de utilizar localStorage de mi web local APP, aquí está la parte WebView inicialización:HTML localStorage es nulo en Android al usar vista web
static class MyWebView extends WebView
{
public MyWebView(Context context)
{
super(context);
this.getSettings().setJavaScriptEnabled(true);
//enable support for DOM Storage and Database
this.getSettings().setDatabaseEnabled(true);
this.getSettings().setDomStorageEnabled(true);
String databasePath = context.getDir("database", Context.MODE_PRIVATE).getPath();
this.getSettings().setDatabasePath(databasePath);
this.setVerticalScrollbarOverlay(true);
} }
y aquí está la aplicación de prueba de JavaScript:
function testStorage()
{
var storage = window.localStorage;
if (storage) {
try {
storage.setItem("name", "Hello World!"); //saves to the database, “key”, “value”
} catch (e) {
alert(e.message); //data wasn’t successfully saved due to quota exceed so throw an error
}
document.write(storage.getItem("name")); //Hello World!
storage.removeItem('name');
}
else {
alert('Your browser does not support HTML5 localStorage. Because Storage is' + storage);
}
}
pero el problema es que el almacenamiento local es siempre nula, he comprobado los permisos y ha creado una WebChromeClient con
@Override
public void onExceededDatabaseQuota(String url,
String databaseIdentifier,
long currentQuota,
long estimatedSize,
long totalUsedQuota,
WebStorage.QuotaUpdater quotaUpdater)
{
quotaUpdater.updateQuota(estimatedSize * 2);
}
que nunca se llama. ¿Alguien sabe por qué?
Gracias
se ha marcado su WebCromeClient personalizada en la vista Web? – Flo
sí, tengo el uso de webView.setWebChromeClient ... – Ali