title: save image to sdcard android Directory problem
body: <p>Im trying to save data to sdCard first i tried to saave it privately within app directory on externalStorage using getExternalFilesDir but gives me nullPointerException so i tried the other way given below it worked but when i want to store files into a custom directory that i want to named myself it give me error:</p>
  
  <pre><code>FileOutputStream os;
  dirName = "/mydirectory/";
          try {  
              if (android.os.Environment.getExternalStorageState().equals(
                      android.os.Environment.MEDIA_MOUNTED)){
                  File sdCard = Environment.getExternalStorageDirectory();
                  File dir = new File (sdCard.getAbsolutePath() + dirName);
                  dir.mkdirs();
                  //File file = new File(this.getExternalFilesDir(null), this.dirName+fileName); //this function give null pointer exception so im using other one
                  File file = new File(dir, dirName+fileName);
                  os = new FileOutputStream(file);
              }else{
                  os = context.openFileOutput(fileName, MODE_PRIVATE);
              }
              resizedBitmap.compress(CompressFormat.PNG, 100, os);
              os.flush();
              os.close();
          }catch(Exception e){
  
          }
  </code></pre>
  
  <p><strong>ErrorLog:</strong></p>
  
  <p>java.io.FileNotFoundException: /mnt/sdcard/mvc/mvc/myfile2.png (No such file or directory)</p>