Using sessionStorage in a webview

by hansamann » Wed, 16 Jun 2010 04:55:02 GMT

Sponsored Links
 Hi all,

I am trying to set a flag for the current session in the webview. I
enabled the DOM storage API:


In my HTML page, loaded from the assets directory, I then execute a
small piece of javascript like this:

                        if (!sessionStorage.flag)
                                        //do stuff once per session
                                        sessionStorage.flag = true;
                                //do nothing

Problem: the //do stuff once per session section is always entered, it
seems the flag is set but each orientation change reloads the complete
HTML page and all the session state is completely lost.

I wanted to use the flag to execute a piece of code once, and even if
the user turns the device, (in which the HTML page seems to be
reloaded, for whatever reason), not execute the code again.

Any ideas?
Is this just broken becaus I load the HMTL resource from the local
package, from the assets directory?



Other Threads

1. Android, dom4j and jaxen...


I am about writing an application for Android. It should parse an XML
file which is an internet resource. As Android does not support XPath
I did some research and found the same article as mentioned above.
Sadly, I can't get it to work. After instantiating the SAXReader the
application debugging stops:

URL url = new URL(Url);
SAXReader reader = new SAXReader(); // Here debugging stops/goes to
Walhalla without exception
Document xmlDoc =;

Does anybody know what I did wrong or what could be wrong?

Thanks in advance!

P.S.: I posted my question in the article, sorry about that. But I
thought that this group is the very right place for the question...


2. Simple question... how do I open the browser?

You need to use an intent

startActivity(new Intent(Intent.ACTION_VIEW, newUri ));


3. retrive checked CheckBoxes鈥檚 items in Listview

4. Application flow/interaction graphing

5. Dalvik Turbo

6. Hey Mr or Ms Moderator...

7. Share intent