I use below code to get photo’s path and id:
String[] projection = {MediaStore.Images.Media._ID, MediaStore.Images.Media.DATA, MediaStore.Images.ImageColumns.DATA};
Cursor cursor = managedQuery( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null, null, MediaStore.Images.Media._ID);
int count = cursor.getCount();
int image_column_index = cursor.getColumnIndex(MediaStore.Images.Media._ID);
int image_path_index = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
int i;
for(i = 0; i < count; i++) {
cursor.moveToPosition(i);
long id = cursor.getInt(image_column_index);
String p = cursor.getString(image_path_index);
photo.add(id, p);
}
And use below code to get thumbnail:
bitmap = MediaStore.Images.Thumbnails.getThumbnail(this.getApplicationContext().getContentResolver(), id, MediaStore.Images.Thumbnails.MICRO_KIND, null);
While I delete one photo by its path.
The thumbnail of the delete one’s still exist.
How to delete the thumbnail at the same time?
You should be able to use the
idfrom the query for the images(theMediaStore.Images.Media._IDcolumn) and then query theMediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URIto delete the thumbnail with theMediaStore.Images.Thumbnails.IMAGE_IDequal to that id(IMAGE_IDis the same id as the id fromMediaStore.Images.Media._ID).I didn’t play much with the
MediaStoreso this could be wrong.