I have tried to open particular folder in gallary as below code but it didn't work for me, and getting error for Unable to find item.
fun openDirectoryInGallery(context: Context, directory: String) {
val intent = Intent(Intent.ACTION_VIEW)
val file = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES), directory)
} else {
File(Environment.DIRECTORY_PICTURES.plus(File.separator).plus(directory))
}
intent.setDataAndType(Uri.withAppendedPath(Uri.fromFile(file), directory), "*/*")
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(context, Intent.createChooser(intent, "Open folder"), Bundle())
}