title: Access denied using local storage in Android WebView
body: <p>I've got an Android webview, that I believe has everything required to access and use localStorage, however, I'm seeing an "Access denied" error in the console when trying to use local storage. <code>Uncaught SecurityError: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.</code></p>
  
  <p>Can anyone spot a problem?</p>
  
  <p>JavaScript Code:</p>
  
  <pre><code>function localStorageTest() {
    // Check browser support
    if (typeof(Storage) != "undefined") {
      // Store
      localStorage.setItem("lastname", "Smith");
      // Retrieve
      document.getElementById("console").innerHTML = localStorage.getItem("lastname");
    } else {
      document.getElementById("console").innerHTML = "Sorry, your browser does not support Web Storage...";
    }
  }
  </code></pre>
  
  <p>Here's the Android code:</p>
  
  <pre><code>    // Enable javascript
      WebSettings settings = getSettings();
      settings.setJavaScriptEnabled(true);
      settings.setDomStorageEnabled(true);
      settings.setDatabaseEnabled(true);
  
      // Create database folder
      String databasePath = getContext().getDir("databases", Context.MODE_PRIVATE).getPath();
      getSettings().setDatabasePath(databasePath);
  
      getContext().getPackageName() + "/databases/");
  
      settings.setAppCacheEnabled(true);
      settings.setSaveFormData(true);;
      settings.setLoadWithOverviewMode(true);
      settings.setSaveFormData(true);
  </code></pre>