Question: So i have this code for getting images with mediastore :

```
int dataIndex = mMediaStoreCursor.getColumnIndex(MediaStore.Files.FileColumns.DATA );

mMediaStoreCursor.moveToPosition(position);
String dataString = mMediaStoreCursor.getString(dataIndex);
Uri mediaUri = Uri.parse("file://" + dataString);
return mediaUri;

```

This good gets all the images in the pictures folder, i would like to change that to get all the images in a specific folder, which will be passed in as a string. e.g `{ android/picture/specificfolder/}`

Answer: 
```
val DIRECTORY_NAME = "%your_folder_name%"

val selection = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
    MediaStore.MediaColumns.RELATIVE_PATH + " like ? "
else MediaStore.Images.Media.DATA + " like ? "

val selectionArgs = arrayOf(APP_RESOURCE_DIRECTORY_NAME)

val cursor = context.contentResolver.query(
        MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
        null,
        selection,
        selectionArgs,
        null)

```
Check this [post](https://stackoverflow.com/questions/30407581/get-mediastore-path-of-a-specific-folder)

It advice you to use cursor and pass the folder needed in the projection.

the relevant answer from teh post:

```html
mediaCursor = getContentResolver().query( MediaStore.Files.getContentUri("external"),
                null,
                MediaStore.Images.Media.DATA + " like ? ",
                new String[] {"%YOUR_FOLDER_NAME%"},
                null);
```