title: how to delete an image from android when its URI is known?
body: <p>Im developing an android app which selects an image from the gallery in one activity and displays it in another.But when I try to delete the selected image it doesnt delete.I'm passing its uri between the two activies. Many thanks in Advance!!!!</p>
  
  <p>Here's my Code :</p>
  
  <p>ACTIVITY HOMESCREEN</p>
  
  <pre><code>protected void onActivityResult(int requestCode, int resultCode, Intent data) {
       super.onActivityResult(requestCode, resultCode, data);
  
       if (requestCode == PICK_IMAGE_REQUEST &amp;&amp; resultCode == RESULT_OK &amp;&amp; data != null &amp;&amp; data.getData() != null) {
            Uri uri = data.getData();
            Intent i = new Intent(this, Imageviewer.class);       
            i.putExtra("imgpath", uri.toString());
            startActivity(i);
       }
  }
  </code></pre>
  
  <p>IMAGEVIEWER ACTIVITY :</p>
  
  <pre><code>Uri imageUri;
  imageUri = Uri.parse(intent.getStringExtra("imgpath"));
  File fdelete = new File(imageUri.toString());
  
      if (fdelete.exists()) {
           if (fdelete.delete()) {
                 System.out.println("file Deleted :" );
           } else {
                 System.out.println("file not Deleted :");
           }
      }
  </code></pre>