title: how to create folder in phone memory and save images.
body: <p>how to create new folder "MyFolder" in phone memory and save all captured images on that folder?
  Please help me. The following code save all images to Phone's default Image gallery. I want to create new folder and save all captured images on that folder. what should I do?</p>
  
  <pre><code>    public class PhotoCaptureExample extends Activity 
    {
  protected Button _button;
  protected ImageView _image;
  protected TextView _field;
  protected String _path;
  protected boolean _taken;
  
  protected static final String PHOTO_TAKEN   = "photo_taken";
  
   @Override
    public void onCreate(Bundle savedInstanceState) 
   {
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.main);
  
      _image = ( ImageView ) findViewById( R.id.image );
      _field = ( TextView ) findViewById( R.id.field );
      _button = ( Button ) findViewById( R.id.button );
      _button.setOnClickListener( new ButtonClickHandler() );
     ;
    _path = Environment.getExternalStorageDirectory() + "/myfolder   
   /"+System.currentTimeMillis()+".jpg";
  
  
  
  
      File dir = new File(_path );
      try{
        if(dir.mkdir()) {
           System.out.println("Directory created");
        } 
        else {
           System.out.println("Directory is not created");
        }}
        catch(Exception e){
  
      }  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  }
  
  public class ButtonClickHandler implements View.OnClickListener 
  {
      public void onClick( View view ){
          Log.i("MakeMachine", "ButtonClickHandler.onClick()" );
          startCameraActivity();
      }
  }
  
  protected void startCameraActivity()
  {
      Log.i("MakeMachine", "startCameraActivity()" );
      File file = new File( _path );
      Uri outputFileUri = Uri.fromFile( file );
  
      Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE );
      intent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri );
  
      startActivityForResult( intent, 0 );
  }
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) 
  {   
      Log.i( "MakeMachine", "resultCode: " + resultCode );
      switch( resultCode )
      {
          case 0:
              Log.i( "MakeMachine", "User cancelled" );
              break;
  
          case -1:
              onPhotoTaken();
              break;
      }
  }
  
  protected void onPhotoTaken()
  {
      Log.i( "MakeMachine", "onPhotoTaken" );
  
      _taken = true;
  
      BitmapFactory.Options options = new BitmapFactory.Options();
      options.inSampleSize = 4;
  
      Bitmap bitmap = BitmapFactory.decodeFile( _path, options );
  
      _image.setImageBitmap(bitmap);
  
      _field.setVisibility( View.GONE );
  }
  
  @Override 
  protected void onRestoreInstanceState( Bundle savedInstanceState){
      Log.i( "MakeMachine", "onRestoreInstanceState()");
      if( savedInstanceState.getBoolean( PhotoCaptureExample.PHOTO_TAKEN ) ) {
          onPhotoTaken();
      }
  }
  
  @Override
  protected void onSaveInstanceState( Bundle outState ) {
      outState.putBoolean( PhotoCaptureExample.PHOTO_TAKEN, _taken );
  }
  }
  </code></pre>