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:

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

--



Other Threads

1. why do I get null pointer with findWiewById ?



Because you cannot use findViewById(R.layout.main). findViewById()
uses R.id values. You need to associate an android:id with any widget
you expect to load via findViewById(), and use the R.id equivalent of
that ID value.

-- 
Mark Murphy
CommonsWare
mmur...@commonsware.com
http://commonsware.com

-- 

2. How to override methods for existing framework classes



Certainly not the *Manager classes. If you look at the source code for
those, you will notice that they tend to be clients for remote
services exporting AIDL interfaces.

-- 
Mark Murphy
CommonsWare
mmur...@commonsware.com
http://commonsware.com

-- 

3. SQLite db limitations for Android app

4. why do I get null pointer with findWiewById ?

5. How to override methods for existing framework classes

6. connectionless WAP Push (SMS Push)

7. How global is the app market?