title: when cancel photo a ghost file is created cannot delete
body: <p>I created an app that allows you to save a photo with a specific name, the process is: 1-You write the name 2-You write the type of operation 3-You press take picture 4-All the info in 1&amp;2 is put into the name and it takes you to the camera.</p>
  
  <p>When you take the picture everything works fine, but if you close the camera instead of taking the photograph a ghost file is created, with a size of 0 bytes, and when you open it with the gallery, it says file does not exist.</p>
  
  <pre><code> int imgNbr = 0;
  values = new ContentValues();
  do{
      file = new File(Environment.getExternalStorageDirectory() + "/" + containerId.getText().toString() + "_" + dateInfo + "_" + eventType + "_" + imgNbr + ".png");
      Log.d("TAG", Integer.toString(imgNbr));
      values.put(MediaStore.Images.Media.DATA, Environment.getExternalStorageDirectory() + "/" + containerId.getText().toString() + "_" + dateInfo + "_" + eventType + "_" + imgNbr + ".png");
      values.put(MediaStore.Images.Media.TITLE, containerId.getText().toString() + "_" + dateInfo + "_" + eventType + "_" + imgNbr+ ".png");
      imgNbr++;
  }
  while(file.exists());
  
  Log.d("TAG", "OUT OF WHILE WITH VALUE" + Integer.toString(imgNbr-1));
  
  imageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
  
  Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
  intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
  startActivityForResult(intent, PICTURE_RESULT);
  </code></pre>
  
  <p>I tried to delete it manually on activity result but it does not work, all the logs return false</p>
  
  <pre><code>@Override @Nullable
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      if(resultCode == RESULT_OK &amp;&amp; requestCode == PICTURE_RESULT){
          Toast.makeText(getApplicationContext(),"Imagen guardada correctamente",Toast.LENGTH_SHORT).show();
      }
      else if (resultCode == RESULT_CANCELED &amp;&amp; requestCode == PICTURE_RESULT){
          //file.delete();
  
          Log.d("TAG", "file.isFile()" + file.isFile());
          Log.d("TAG", "file.canRead()" + file.canRead());
          Log.d("TAG", "file.delete()" + file.delete());}}
  </code></pre>