title: Android 4.0.1 breaks WebView HTML 5 local storage?
body: <p>I have a simple html5 test page which uses LocalStorage to display / save  / redisplay a piece of data.</p>
  
  <p>This code works perfectly in Android 2.3.x but <em>logs</em> an exception in 4.0.1 on line 18 of the html which is the frist <code>localStorage.getItem()</code> call and at this point the JS stops.</p>
  
  <p>Exception: <code>Uncaught Error: SECURITY_ERR: DOM Exception 18 at /data/data/my.app.name/app_htmlData:18</code>
  I've also tried setting the database path to <code>getCacheDir()</code> with the same result.</p>
  
  <pre><code>String htmlContent = "HTML content listed below";    
  File sharedDir = getActivity().getDir("htmlData", Context.MODE_PRIVATE);
  WebView browser = (WebView)v.findViewById(R.id.wvBrowser);
  
  browser.setWebChromeClient(new WebChromeClient(){
      public void onExceededDatabaseQuota(String url, String databaseIdentifier, long  currentQuota, long estimatedSize,   long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater) { 
              quotaUpdater.updateQuota(estimatedSize * 2); 
          }
      });       
  browser.setWebViewClient(new WebViewClient(){
      @Override
      public void onPageFinished(WebView view, String url){
  
          view.loadUrl("javascript:doTest()");
  
      });
  
  browser.getSettings().setDatabaseEnabled(true);
  browser.getSettings().setDatabasePath(sharedDir.getPath());
  browser.getSettings().setDomStorageEnabled(true);
  browser.loadDataWithBaseURL(mSharedDir.getPath(), 
              htmlContent, 
              "text/html", 
              "utf-8", 
              null);
  </code></pre>
  
  <p>The HTML that the page is rendering is as follows:</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt;
  &lt;head&gt;
      &lt;title&gt;Simple localStorage test&lt;/title&gt;
      &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
  
          function doTest() {
              $('#stuff').append('&lt;p&gt;reading&lt;/p&gt;');
              var item = read();
  
              $('#stuff').append('&lt;p&gt;writing&lt;/p&gt;');
              localStorage['bar'] = new Date().toUTCString();
  
              $('#stuff').append('&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;reading again&lt;/p&gt;');
              read();
          }
          function read() {
              var item = localStorage.getItem('bar');
              if (item == null || (item == undefined)) {
                  item = '';
              }
              $('#stuff').append('&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;item: ' + item + '&lt;/p&gt;');
  
           return item;
          }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;p&gt;-Simple localStorage test-&lt;/p&gt;
      &lt;div id="stuff"&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Source available <a href="http://dl.dropbox.com/u/9938553/localstorage_bug.zip" rel="nofollow noreferrer" title="here">here</a></p>