title: Image directory not created when i take picture from my app
body: <p>I am working in <code>android studio</code>. Building an <code>app</code> in which i am using a camera. When i run my app the app works fine. I capture the image it does captured the image. But the folder i created is not showing in my gallery. I am saving images in my <code>local storage</code> and not in <code>SD CARD</code>. I was very curious that why the folder is not created as it doesn't gives me any error so it should be in my gallery. So i restarted my device and after restarting i can see the folder in my gallery and the images taken in it. I again open the app and took images from it but again the images were not shown in the folder. </p>
  
  <p>Below is my code in which i am making ta directory for saving images</p>
  
  <pre><code>protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   if(requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE)
      {
          if(resultCode == Activity.RESULT_OK)
          {
              Bitmap bmp = (Bitmap)data.getExtras().get("data");
              ByteArrayOutputStream stream = new ByteArrayOutputStream();
  
              bmp.compress(Bitmap.CompressFormat.JPEG, 100, stream);
              byte[] byteArray = stream.toByteArray();
  
              // convert byte array to Bitmap
              Bitmap bitmap = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
  
              if(isStoragePermissionGranted())
              {
                  SaveImage(bitmap);
              }
  
  
          }
  
  }
   private void SaveImage(Bitmap finalBitmap) {
  
      String root = Environment.getExternalStorageDirectory().getAbsolutePath().toString();
      Log.v(LOG_TAG, root);
      File myDir = new File(root + "/captured_images");
      myDir.mkdirs();
      Random generator = new Random();
      int n = 1000;
      n = generator.nextInt(n);
      String fname = "Image-" + n + ".jpg";
      File file = new File(myDir,fname);
      if (file.exists())file.delete();
      try {
          FileOutputStream out = new FileOutputStream(file);
          finalBitmap.compress(Bitmap.CompressFormat.JPEG,100,out);
          out.flush();
          out.close();
  
  
      } catch (Exception e) {
          e.printStackTrace();
      }
  
  }
  </code></pre>
  
  <p>Below is the picture of my debugging</p>
  
  <p><a href="https://i.stack.imgur.com/7zTlO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7zTlO.png" alt="enter image description here"></a> </p>
  
  <p>**Note: **</p>
  
  <p>As i am using native camera so the pictures are saved in the camera roll folder i.e. the default folder in my device. But the image saved there is not the compressed one, the compress image should be saved in my created folder.</p>
  
  <p>I am stuck to it and don't know what to do. </p>
  
  <p>Any help would be highly appreciated.</p>