Tuesday, June 15, 2010

[android-developers] Using sessionStorage in a webview

Hi all,

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

mWebView.getSettings().setDomStorageEnabled(true);

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;
}
else
{
//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?

Cheers
SVen

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment