title: Android: IOException: Permission denied
body: <p>I'm creating/saving file on SD card. This is the code:</p>
  
  <pre><code>File sdDir = Environment.getExternalStorageDirectory();
  public void btnsave_clicked(View v) throws FileNotFoundException, IOException{
       File f;
        f=new File(sdDir, "deposit.dma");
        if(!f.exists())
        f.createNewFile();
  ...
  }
  </code></pre>
  
  <p>But when I click the button, it throws "Permission denied".
  Don't ask me for add uses-permission.</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
  </code></pre>
  
  <p>I've already added this in Manifest.</p>
  
  <p>What should I do?
  LogCat info:</p>
  
  <pre><code>10-19 20:25:14.681: E/AndroidRuntime(29016): FATAL EXCEPTION: main
  10-19 20:25:14.681: E/AndroidRuntime(29016): java.lang.IllegalStateException: Could not execute method of the activity
  10-19 20:25:14.681: E/AndroidRuntime(29016):    at android.view.View$1.onClick(View.java:2168)
  10-19 20:25:14.681: E/AndroidRuntime(29016):    at android.view.View.performClick(View.java:2552)
  10-19 20:25:14.681: E/AndroidRuntime(29016):    at android.view.View$PerformClick.run(View.java:9229)
  10-19 20:25:14.681: E/AndroidRuntime(29016):    at android.os.Handler.handleCallback(Handler.java:587)
  10-19 20:25:14.681: E/AndroidRuntime(29016):    at android.os.Handler.dispatchMessage(Handler.java:92)
  10-19 20:25:14.681: E/AndroidRuntime(29016):    at android.os.Looper.loop(Looper.java:130)
  10-19 20:25:14.681: E/AndroidRuntime(29016):    at android.app.ActivityThread.main(ActivityThread.java:3701)
  10-19 20:25:14.681: E/AndroidRuntime(29016):    at java.lang.reflect.Method.invokeNative(Native Method)
  10-19 20:25:14.681: E/AndroidRuntime(29016):    at java.lang.reflect.Method.invoke(Method.java:507)
  10-19 20:25:14.681: E/AndroidRuntime(29016):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
  10-19 20:25:14.681: E/AndroidRuntime(29016):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
  10-19 20:25:14.681: E/AndroidRuntime(29016):    at dalvik.system.NativeStart.main(Native Method)
  10-19 20:25:14.681: E/AndroidRuntime(29016): Caused by: java.lang.reflect.InvocationTargetException
  10-19 20:25:14.681: E/AndroidRuntime(29016):    at java.lang.reflect.Method.invokeNative(Native Method)
  10-19 20:25:14.681: E/AndroidRuntime(29016):    at java.lang.reflect.Method.invoke(Method.java:507)
  10-19 20:25:14.681: E/AndroidRuntime(29016):    at android.view.View$1.onClick(View.java:2163)
  10-19 20:25:14.681: E/AndroidRuntime(29016):    ... 11 more
  10-19 20:25:14.681: E/AndroidRuntime(29016): Caused by: java.io.IOException: Permission denied
  10-19 20:25:14.681: E/AndroidRuntime(29016):    at java.io.File.createNewFileImpl(Native Method)
  10-19 20:25:14.681: E/AndroidRuntime(29016):    at java.io.File.createNewFile(File.java:1257)
  10-19 20:25:14.681: E/AndroidRuntime(29016):    at org.brotheroftux.depositmaster.MainActivity.btnsave_clicked(MainActivity.java:43)
  10-19 20:25:14.681: E/AndroidRuntime(29016):    ... 14 more
  </code></pre>