title: take a picture and save it using android studio
body: <p>I wrote a program that can take a picture .
  The problem is when I try to save it in DIRECTORY_PICTURES I can't find the picture I took in pictures directory what is the wrong with my code the?.
  The program I wrote open the camera with no problem and I can take
  the picture successfully but there is no image in pictures directory    </p>
  
  <pre><code> ImageView mImageView;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      mImageView=(ImageView)findViewById(R.id.imageView) ;
  }
  
  
  static final int REQUEST_IMAGE_CAPTURE=1;
  public void bucapture(View view) {
      Intent takePictureIntent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
      if(takePictureIntent.resolveActivity(getPackageManager())!=null){
          startActivityForResult(takePictureIntent,REQUEST_IMAGE_CAPTURE);
      }
  
  }
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      if(requestCode==REQUEST_IMAGE_CAPTURE &amp;&amp; resultCode==RESULT_OK){
          Bundle extras=data.getExtras();
          Bitmap imageBitmap=(Bitmap) extras.get("data");
          mImageView.setImageBitmap(imageBitmap);
          try {
              createImageFile();
              galleryAddpic();
  
          }catch (Exception ex){
              ex.printStackTrace();
          }
  
      }
  }
  
  String mCurrentPhotpPath;
  //create image name
  private File createImageFile() throws IOException {
      String timeStamp=new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
      String imageFileName="JPGE"+timeStamp+"_";
      File storgeDir= Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
      File image=File.createTempFile(imageFileName,".jpg",storgeDir);
      mCurrentPhotpPath="file:"+image.getAbsolutePath();
      return image;
  }
  
  
  //save image
  private void galleryAddpic(){
      Intent mediaScanIntent=new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
      File f=new File(mCurrentPhotpPath);
      Uri contentUri=Uri.fromFile(f);
      mediaScanIntent.setData(contentUri);
      this.sendBroadcast(mediaScanIntent);
  
    }
  }
  </code></pre>