title: How do I set delete permission?
body: <p>I'm writing a program, a part of which is to delete files in a certain folder (in root of program). Currently, the files are NOT created by the program, but externally - but in the future they may or may not be created/edited by the program itself.</p>
  
  <p>Now the issue:</p>
  
  <p>When I try to delete a file, I get permission exception. After a lot of checking, debugging and research, I wrote this code:</p>
  
  <pre><code>private void checkAndDelete(int n, String fileName) {
      // TODO: file permission error
      if (n == JOptionPane.YES_OPTION) {
          File file = new File(fileName);
          file.setWritable(true);
          SecurityManager s = new SecurityManager();
          s.checkDelete(fileName);
          System.out.println(file);
          if(file.delete()) {
              JOptionPane.showMessageDialog(null, "Deletion successful!");
              initializeNorth();
          } else {
              JOptionPane.showMessageDialog(null, "Deletion failed!");
          }
      }
  }
  </code></pre>
  
  <p><code>n</code> is the value when user clicks yes or no in the dialog box confirming deletion, <code>fileName</code> is the file name.</p>
  
  <p>Now, the <code>checkDelete</code> method throws this:</p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.security.AccessControlException: access denied ("java.io.FilePermission" "DB/fun trivia.kgf" "delete")
  </code></pre>
  
  <p>So I have narrowed the problem - permission problem. If it matters, I have the file in dropbox (where all my projects are). The file exists, is readable and writable. I've done all checks. The problem is only for permission.</p>
  
  <p>How do I fix this?</p>
  
  <p>EDIT: I tried to change location of my file to be on my local system, but it has the same error. So its not a problem while only on dropbox.</p>