title: Database in Chrome Packaged Apps
body: <p>I have been trying to implement a local database in a packaged app which does not seem to be working.</p>
  
  <p>I tried using <a href="http://pouchdb.com/" rel="nofollow">PouchDB</a> which is a layer over IndexedDB and then I tried using the native IndexedDB API. Both don't work and I receive the same message: <code>An attempt was made to break through the security policy of the user agent.</code></p>
  
  <p>I Googled about database methods for packaged apps but only found info on how to use the <a href="https://developer.chrome.com/apps/fileSystem" rel="nofollow">FileSystem API</a>.</p>
  
  <p>Any links pointing towards database implementation on Chrome packaged apps will be really helpful (or just let me know if I am doing something wrong).</p>
  
  <p><strong>Sample code to initiate IndexedDB:</strong></p>
  
  <pre><code>idbSupported = false;
  db = '';    
  if("indexedDB" in window) {
      idbSupported = true;
  }
  if(idbSupported) {
      var openRequest = indexedDB.open("test",1);
  
      openRequest.onupgradeneeded = function(e) {
          console.log("Upgrading...");
      }
  
      openRequest.onsuccess = function(e) {
          console.log("Success!");
          db = e.target.result;
      }
  
      openRequest.onerror = function(e) {
          console.log("Error");
          console.dir(e);
      }
  }
  </code></pre>
  
  <p><strong>Permissions inside manifest file</strong></p>
  
  <pre><code>"permissions": ["http://*/*", "https://*/*","storage","fileSystem"]
  </code></pre>