Cheok Yan Cheng
Cheok Yan Cheng

Reputation: 42642

Delete image and thumbnail created by MediaStore.Images.Media.insertImage

I realize

MediaStore.Images.Media.insertImage (ContentResolver cr, Bitmap source, String title, String description)

will create 2 files (image and thumbnail)

How can I delete both created images?

Upvotes: 4

Views: 1774

Answers (1)

Ifrah
Ifrah

Reputation: 209

use this command using the id of the images you wish to delete:

mediaStoreIds.add(mediaStoreId);
context.getContentResolver().delete(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, BaseColumns._ID + "=?", new String[]{Long.toString(mediaStoreIds.get(id))});

and the following to delete the thumbnails:

mediaStoreIds.add(mediaStoreId);
context.getContentResolver().delete(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, BaseColumns._ID + "=?", new String[]{Long.toString(mediaStoreIds.get(id))});

Upvotes: 1

Related Questions