Skip to content Skip to sidebar Skip to footer

Android Studio App Edited Images Not Showing Up In Gallery

I created a simple android app for adding frames and cropping images, now after the editing is done the pictures are saved in android root>app folder but non of these pictures s

Solution 1:

try this add below code after saving image

ContentValuesvalues=newContentValues();
values.put(Images.Media.TITLE, "title");
values.put(Images.Media.DESCRIPTION, "description");
values.put(Images.Media.DATE_TAKEN, System.currentTimeMillis());
values.put(Images.ImageColumns.BUCKET_ID, root.toString().toLowerCase(Locale.US).hashCode());
values.put(Images.ImageColumns.BUCKET_DISPLAY_NAME, root.getName().toLowerCase(Locale.US));
values.put("_data", root.getAbsolutePath());
ContentResolvercr= getContentResolver();
cr.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);

Solution 2:

Add these code after you save the image

sendBroadcast(newIntent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + Environment.getExternalStorageDirectory())));

The Media Scanning is only done when the system Bootup. So you need to tell the media scanner to re-scan the files.

Post a Comment for "Android Studio App Edited Images Not Showing Up In Gallery"