title: Android says cannot resolve method 'getExternalFilesDir(null)'
body: <p>I am using Android Studio to try to write a file to external storage.  </p>
  
  <p>Other posts have recommended I do this using <code>getExternalFilesDir(null)</code>, but I get the message <code>Cannot resolve method 'getExternalFilesDir(null)'</code>.</p>
  
  <pre class="lang-java prettyprint-override"><code> public void makeFile() {
      try {
          String storageState = Environment.getExternalStorageState();
          if (storageState.equals(Environment.MEDIA_MOUNTED)) {
              File file = new File(getExternalFilesDir(null), "outputFile.txt");
              FileOutputStream fos = new FileOutputStream(file);
              String text = "Hello, world!";
              fos.write(text.getBytes());
              fos.close();
          }
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>I haven't been able to find any way to get rid of this error.  Thanks in advance for any solutions to the problem.</p>