title: Environment.getExternalStorageDirectory() deprecated in API level 29 java
body: <p>Working on android Java, recently updated SDK to API level 29 now there is a warning shown which states that</p>
  
  <p><code>Environment.getExternalStorageDirectory()</code> is deprecated in API level 29</p>
  
  <p>My code is</p>
  
  <pre><code>private void saveImage() {
  
  if (requestPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
  
      final String folderPath = Environment.getExternalStorageDirectory() + "/PhotoEditors";
      File folder = new File(folderPath);
      if (!folder.exists()) {
          File wallpaperDirectory = new File(folderPath);
          wallpaperDirectory.mkdirs();
      }
  
  
      showLoading("Saving...");
      final String filepath=folderPath
                  + File.separator + ""
                  + System.currentTimeMillis() + ".png";
      File file = new File(filepath);
  
      try {
          file.createNewFile();
          SaveSettings saveSettings = new SaveSettings.Builder()
                  .setClearViewsEnabled(true)
                  .setTransparencyEnabled(true)
                  .build();
          if(isStoragePermissionGranted() ) {
              mPhotoEditor.saveAsFile(file.getAbsolutePath(), saveSettings, new PhotoEditor.OnSaveListener() {
              @Override
              public void onSuccess(@NonNull String imagePath) {
                  hideLoading();
                  showSnackbar("Image Saved Successfully");
                  mPhotoEditorView.getSource().setImageURI(Uri.fromFile(new File(imagePath)));
                  sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,Uri.fromFile(new File(filepath))));
                  Intent intent = new Intent(EditImageActivity.this, StartActivity.class);
                  startActivity(intent);
                  finish();
  
              } 
  
              @Override
              public void onFailure(@NonNull Exception exception) {
                  hideLoading();
                  showSnackbar("Failed to save Image");
              }
         });
     }
  </code></pre>
  
  <p>What will be the alternative for this?</p>