How to delete image from sd card after sharing successfully
<p>I want to delete the image from sdcard after sharing the image</p>

<pre><code>protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) 
{
case TAKE_IMAGE:
    try {
        if (resultCode == RESULT_OK) {

            // we need to update the gallery by starting MediaSanner
            // service.
            mScanner = new MediaScannerConnection(ProfilePicFromCamera.this,new MediaScannerConnection.MediaScannerConnectionClient()
            {
               public void onMediaScannerConnected() {
                   mScanner.scanFile(imageUri.getPath(),null /*mimeType*/);
            }           

                public void onScanCompleted(String path, Uri uri) {
                    if (path.equals(imageUri.getPath())) {
                        mScanner.disconnect();
                        ProfilePicFromCamera.this.runOnUiThread(new Runnable() {
                                public void run() {
                                    updateUI();
                            }
                        });
                    }
                }
            });
            mScanner.connect();

        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    break;
case UPLOAD_IMAGES:
     if(requestCode==UPLOAD_IMAGES)
        {
            if(requestCode==UPLOAD_IMAGES &amp;&amp; resultCode==Activity.RESULT_OK)    
            {
                            if(file.exists())
                                file.delete();  
                Toast.makeText(this, "Mail sent.", Toast.LENGTH_SHORT).show();
            }
            else if (requestCode==UPLOAD_IMAGES &amp;&amp; resultCode==Activity.RESULT_CANCELED)
            {
                Toast.makeText(this, "Mail canceled.", Toast.LENGTH_SHORT).show();
            }
            else 
            {
                Toast.makeText(this, "Please try again.", Toast.LENGTH_SHORT).show();
            }
        }   
    break;

}
}
</code></pre>
