title: Cannot resolve method getExternalFilesDir()
body: <p>I am migrating to android 10 and tried using <code>getExternalFilesDir()</code> instead of <code>Environment.getExternalStorageDirectory()</code>. However, the IDE  Cannot resolve the method. Please help to fix it. Thanks in advance!</p>
  <pre><code> public String saveImageToSD(Bitmap bmp, String filename, Bitmap.CompressFormat format) {
      File file2 = null;
      try {
          String path1 = getExternalFilesDir().toString();
          FileOutputStream fos = null;
          ByteArrayOutputStream bytes = new ByteArrayOutputStream();
          bmp.compress(format, 100, bytes);
          File file1 = new File(path1 + &quot;/s/Gallery/&quot;);
          if (!file1.exists()) {
              file1.mkdirs();
          }
          // Log.e(&quot;TAG&quot;, &quot;File name : &quot; + file1.getAbsolutePath());
          file2 = new File(file1, filename);
          try {
              file2.createNewFile();
          } catch (IOException e) {
              e.printStackTrace();
          }
          try {
              fos = new FileOutputStream(file2);
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          }
          try {
              fos.write(bytes.toByteArray());
              fos.close();
              Log.e(&quot;Success&quot;, &quot;Final Image Saved - &quot; + filename);
          } catch (IOException e) {
              e.printStackTrace();
          }
  
          Rowan.FinalBitmap = bmp;
          FinalURI = &quot;&quot; + path1 + &quot;/s/Gallery/&quot; + filename;
  
  
          ContentValues image = new ContentValues();
          String dateStr = &quot;04/05/2010&quot;;
  
          SimpleDateFormat curFormater = new SimpleDateFormat(&quot;dd/MM/yyyy&quot;);
          Date dateObj = curFormater.parse(dateStr);
          SimpleDateFormat postFormater = new SimpleDateFormat(&quot;MMMM dd, yyyy&quot;);
         }
   public void mergeAndSave() {
      Bitmap bmOverlay = Bitmap.createBitmap(drawing_view_container.getWidth(), drawing_view_container.getHeight(), Bitmap.Config.ARGB_8888);
  
      try {
          bmOverlay = MainGPUImageView.capture();
  
      } catch (InterruptedException e) {
          e.printStackTrace();
      }
  
      saveImageToSD(bmOverlay, &quot;photox_&quot; + generateRandomName(1000000, 5000000) + &quot;.jpg&quot;, Bitmap.CompressFormat.JPEG);
      Log.i(&quot;TAG&quot;, &quot;Image Created&quot;);
  }
  </code></pre>