Skip to content Skip to sidebar Skip to footer

Using Local Storage On Android Webview

I am experimenting with Android code: I would like to store one value using HTML 5 local storage. For this exercise I' using a page as simple as this one: http://www.w3schools.c

Solution 1:

It appears the empty string DatabasePath is the problem. I tried similar code and with an empty string path, the value does not persist after the app exits. If I define a specific database path, the value persists as expected.

Try:

webSettings.setDatabasePath("/data/data/"+this.getPackageName()+"/databases/");

Solution 2:

If your app use multiple webview you will still have troubles : localStorage is not correctly shared accross all webviews.

If you want to share the same data in multiple webviews the only way is to repair it with a java database and a javascript interface.

This page on github shows how to do this.

hope this help!

Solution 3:

Couldn't get it working on all devices (especially with ICS) - even with database path, enabling DOMStorage etc. - using cookies instead helped me out.

Post a Comment for "Using Local Storage On Android Webview"