title: W/System.err: java.io.IOException: Permission denied when writing file
body: <p>I'm trying to create a file to store the data collected by AudioRecord. But when I do that, android studio show me that:</p>
  
  <pre><code> 04-09 21:23:47.665 28293-28293/com.example.gongk.testfmcwv3 W/art: Before 
      Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
  04-09 21:23:47.845 28293-28293/com.example.gongk.testfmcwv3 W/System.err: java.io.IOException: Permission denied
  04-09 21:23:47.846 28293-28293/com.example.gongk.testfmcwv3 W/System.err:     at java.io.UnixFileSystem.createFileExclusively0(Native Method)
  04-09 21:23:47.846 28293-28293/com.example.gongk.testfmcwv3 W/System.err:     at java.io.UnixFileSystem.createFileExclusively(UnixFileSystem.java:280)
  04-09 21:23:47.846 28293-28293/com.example.gongk.testfmcwv3 W/System.err:     at java.io.File.createNewFile(File.java:948)
  04-09 21:23:47.846 28293-28293/com.example.gongk.testfmcwv3 W/System.err:     at com.example.gongk.testfmcwv3.MainActivity.init(MainActivity.java:82)
  04-09 21:23:47.846 28293-28293/com.example.gongk.testfmcwv3 W/System.err:     at com.example.gongk.testfmcwv3.MainActivity.onCreate(MainActivity.java:63)
  04-09 21:23:47.846 28293-28293/com.example.gongk.testfmcwv3 W/System.err:     at android.app.Activity.performCreate(Activity.java:6912)
  04-09 21:23:47.846 28293-28293/com.example.gongk.testfmcwv3 W/System.err:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
  04-09 21:23:47.846 28293-28293/com.example.gongk.testfmcwv3 W/System.err:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2900)
  04-09 21:23:47.846 28293-28293/com.example.gongk.testfmcwv3 W/System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3008)
  04-09 21:23:47.846 28293-28293/com.example.gongk.testfmcwv3 W/System.err:     at android.app.ActivityThread.-wrap14(ActivityThread.java)
  04-09 21:23:47.846 28293-28293/com.example.gongk.testfmcwv3 W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
  04-09 21:23:47.846 28293-28293/com.example.gongk.testfmcwv3 W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
  04-09 21:23:47.846 28293-28293/com.example.gongk.testfmcwv3 W/System.err:     at android.os.Looper.loop(Looper.java:154)
  04-09 21:23:47.846 28293-28293/com.example.gongk.testfmcwv3 W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6688)
  04-09 21:23:47.846 28293-28293/com.example.gongk.testfmcwv3 W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
  04-09 21:23:47.846 28293-28293/com.example.gongk.testfmcwv3 W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
  04-09 21:23:47.846 28293-28293/com.example.gongk.testfmcwv3 W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
  04-09 21:23:47.866 28293-28300/com.example.gongk.testfmcwv3 W/art: Suspending all threads took: 5.158ms
  </code></pre>
  
  <p>My AndroidManifest.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.gongk.testfmcwv3"&gt;
  
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
      &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
      &lt;uses-permission android:name="android.permission.RECORD_AUDIO" /&gt;
      &lt;uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
  
          &lt;activity android:name=".MainActivity"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>java code:</p>
  
  <pre><code>file = new File(Environment.getExternalStorageDirectory(),"TestFMCWR");
          if (file.exists()) file.delete();
          try {
              file.createNewFile();
          } catch (IOException e) {
              e.printStackTrace();
          }
  </code></pre>
  
  <p>I can't figure out why the permission is not work.</p>