title: Android Camera - Save image into a new folder in SD Card
body: <p>I have a very simple APP which at the moment takes a picture and then saves the image. The problem at the moment is that for some reason i cannot find where the image is being saved to on the phone.</p>
  
  <p>The finished outcome with what i am trying to do is when a picture is took the image then gets saved into a new folder that has been created on the SD Card, but if the folder does not already exist it will have to be made (automaticlly) before the image can be saved.</p>
  
  <p>I have tried to use the answer <a href="https://stackoverflow.com/questions/8402378/how-to-save-image-captured-with-camera-in-specific-folder">in this question</a> but cannot seem to incoporate it without getting the error <code>imageIntent cannot be resolved</code></p>
  
  <p><strong>EDIT: Image now saving into SD Card and creating folder but overwriting the pervious image I need it to save multiple images if any one has any suggestions code has been updated</strong></p>
  
  <p>This is a snippet of my code:</p>
  
  <pre><code>PictureCallback myPictureCallback_JPG = new PictureCallback(){
  
      public void onPictureTaken(byte[] arg0, Camera arg1) {
          // TODO Auto-generated method stub
          /*Bitmap bitmapPicture 
              = BitmapFactory.decodeByteArray(arg0, 0, arg0.length);  */
  
  
          int imageNum = 0;
          Intent imageIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
          File imagesFolder = new File(Environment.getExternalStorageDirectory(), "Punch");
          imagesFolder.mkdirs(); // &lt;----
          String fileName = "image_" + String.valueOf(imageNum) + ".jpg";
          File output = new File(imagesFolder, fileName);
          while (output.exists()){
              imageNum++;
              fileName = "image_" + String.valueOf(imageNum) + ".jpg";
              output = new File(imagesFolder, fileName);
          }
          Uri uriSavedImage = Uri.fromFile(image);
          imageIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
  
  
          OutputStream imageFileOS;
          try {
              imageFileOS = getContentResolver().openOutputStream(uriSavedImage);
              imageFileOS.write(arg0);
              imageFileOS.flush();
              imageFileOS.close();
  
              Toast.makeText(AndroidCamera.this, 
                      "Image saved: ", 
                      Toast.LENGTH_LONG).show();
  
          } catch (FileNotFoundException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
          camera.startPreview();
      }};
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>Code has been updated to now save multiple images in a new folder created on SD Card.</p>