Can't display pictures in the gallery (Android 10+)

436 Views Asked by At

I'm currently having a problem with making my pictures contained in the app/files/Picture folder appear in the gallery with a device running Android 10. I created a folder in Picture called "ticket" (for sorting purposes) and I'm trying to display the entire folder in the gallery.

The following code works perfectly fine with a device running Android 9, but I just can't manage to make it work with the other device.

private void galleryAddPic() {
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
File dir = new File(currentDirPath); // currentDirPath = /storage/emulated/0/Android/data/com.example.app_test_emasolar/files/Pictures/ticket
Uri contentUri = Uri.fromFile(dir);
mediaScanIntent.setData(contentUri);
this.sendBroadcast(mediaScanIntent);}

I also tried to add

android:requestLegacyExternalStorage="true"

to the manifest but nothing changed, I'm still stuck.

Any ideas?

0

There are 0 best solutions below