I am creating an app with a shared transition animation. For this I create an intent with an image. But the image gets stored on the device. But how can I delete this aftere the transition?
Here I share the transition:
Bitmap photo = ((BitmapDrawable) drawable).getBitmap();
String path = MediaStore.Images.Media.insertImage(getContentResolver(), photo, "pic", null);
Uri uri = Uri.parse(path);
intent.putExtra(Intent.EXTRA_STREAM, uri);
And here I recieve the uri:
pic = extras.getParcelable(Intent.EXTRA_STREAM);
And here I try to delete the image, but it doesn't find it:
File fdlt = new File(pic.getPath());
if (fdlt.exists()) {
if (fdlt.delete()) {
Log.e("DELETED", "DELETED");
} else {
Log.e("NOT DELETED", "NOT DELETED");
}
} else {
Log.e("FILE NOT FOUND", "FILE NOT FOUND");
}
Example path of an image: /external/images/media/2750