title: User Cannot Select SQLite db Location from UWP App
body: <p>Using code to <a href="https://github.com/Microsoft/Windows-task-snippets/blob/master/tasks/Folder-access-preservation.md" rel="nofollow">Preserve access to a StorageFolder</a> stolen from <a href="https://github.com/KarlErickson" rel="nofollow">Karl Erickson</a></p>
  
  <pre><code>public static async Task&lt;StorageFolder&gt; GetOrPickAndRememberFolderAsync(string key)
  {
      if (StorageApplicationPermissions.FutureAccessList.ContainsItem(key))
      {
          return await StorageApplicationPermissions.FutureAccessList.GetFolderAsync(key);
      }
      var picker = new FolderPicker();
      picker.FileTypeFilter.Add("*");
      StorageFolder folder = await picker.PickSingleFolderAsync();
      if (folder != null)
      {
          StorageApplicationPermissions.FutureAccessList.AddOrReplace(key, folder);
      }
      return folder;
  }
  </code></pre>
  
  <p>our UWP app is able to browse to and remember the location of a SQLite database chosen by a user. This should give read/write permissions on that folder.</p>
  
  <p>The dbContext is instantiated like this</p>
  
  <pre><code>    public dbContext(string dbPath)
      {
          databasePath = dbPath;
      }
      protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
      {
          optionsBuilder.UseSqlite("Filename=" + databasePath);
      }
  </code></pre>
  
  <p>This code works if the user chooses the default local storage location for the app.</p>
  
  <pre><code>        var picker = new FolderPicker();
          picker.FileTypeFilter.Add("*");
          StorageFolder folder = await picker.PickSingleFolderAsync();
  
          StorageFolder dbFolder = await GetOrPickAndRememberFolderAsync("LocalDbFolder");
          string dbPath = Path.Combine(dbFolder.Path, "MySQLite.db");
  
          using (var db = new dbContext(dbPath))
          {
              db.Database.Migrate();
          }
  </code></pre>
  
  <p>However if the user chooses any other location (such as their Documents folder) the app fails with the error <code>"SQLite Error 14: 'unable to open database file'."</code></p>
  
  <p>Why would that be, given the user has given the app explicit permissions on the selected location through the picker?</p>