画像共有後にSDカードから画像を削除したい
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 && resultCode==Activity.RESULT_OK)
{
if(file.exists())
file.delete();
Toast.makeText(this, "Mail sent.", Toast.LENGTH_SHORT).show();
}
else if (requestCode==UPLOAD_IMAGES && 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;
}
}