title: Use Camera to Take Photos and Save them to the Phone Gallery
body: <p>I am new to Android Studio. I want to capture photo with phone camera by clicking a button, then display the taken photo, and the photo will save automatically in the phone gallery. I have found some online examples but the photo that I captured is not saved inside the gallery. I already used the code below. May I get some help please?</p>
  
  <pre><code>@Override
  public void onClick(View view) {
      switch (view.getId()) {
          case R.id.buttonTakePhoto:
              Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
              startActivityForResult(intent, CAMERA_PIC_REQUEST);
              break;
      }
  } 
  
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      if (requestCode == CAMERA_PIC_REQUEST) {
          Bitmap image = (Bitmap) data.getExtras().get("data");
          ImageView imageview = (ImageView) findViewById(R.id.imageView);
          imageview.setImageBitmap(image);
      }
  }
  </code></pre>