I am experimenting with Android code: I would like to save one value using local HTML 5 storage. For this exercise, I use the page as simple as this one: http://www.w3schools.com/html5/tryit.asp?filename= tryhtml5_webstorage_local_clickcount
My manifest allows me to go online, and this is min-sdk of 7.
Here is my Java code:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); webview = (WebView) findViewById(R.id.webview); WebView webView = (WebView) findViewById(R.id.webview); webView.addJavascriptInterface(new JavaScriptInterface(this), "Android"); WebSettings webSettings = webview.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setDatabasePath(""); webSettings.setDomStorageEnabled(true); webview.setWebChromeClient(new WebChromeClient()); webview.loadUrl("http://www.xyz.com/test.html");
My problem is that when I close the application, the locally stored value no longer exists. I can go to the same page using the default browser, and the value remains constant even after the emulator is closed, which is exactly the behavior I'm looking for.
This is probably something extremely simple ... any ideas?
source share