title: How to Save Captured image File to data/data/<package.name>/cache ?
body: <p>I need to secure the images which i am taking. from android <a href="https://developer.android.com/training/camera/photobasics.html" rel="nofollow noreferrer">Android Training</a>
      i am able to take full sized image. but this is not my need.
  i need to save full sized image to cache dir (/data/data//cache) and i wil delete these cache folder when user leaves my application.</p>
  
  <p>this is  my code, which  the file is successfully created in cache directory. but the file size is zero, no image written</p>
  
  <pre><code>static final int REQUEST_TAKE_PHOTO = 1;
  
  private void dispatchTakePictureIntent() {
      Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
      // Ensure that there's a camera activity to handle the intent
      if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
          File file=null;
          try {
              String fileName = "506214";
              file = File.createTempFile(fileName, null, this.getCacheDir());
          } catch (IOException e) {
              // Error while creating file
          }
          photoURI = Uri.fromFile(file);
          Toast.makeText(this, photoURI.toString(), Toast.LENGTH_SHORT).show();
              takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,photoURI);
              startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
      }
  }
  
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      if(requestCode == REQUEST_TAKE_PHOTO &amp;&amp; resultCode == RESULT_OK){
          camera_image.setImageURI(photoURI);
      }
      super.onActivityResult(requestCode, resultCode, data);
  }
  </code></pre>