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)

```
You can use following method - 

```
public List<String> getFromSdcard()
{
    ArrayList<String> imagePaths = new ArrayList<String>();// list of file paths
    File[] listFile;
    File file= new 

    File(android.os.Environment.getExternalStorageDirectory(),"android/picture/specificfolder/");

    if (file.isDirectory())
    {
        listFile = file.listFiles();

        for (int i = 0; i < listFile.length; i++)
        {

            imagePaths.add(listFile[i].getAbsolutePath());

        }
    }
    return imagePaths;
}

```

to retreive the images use 

```
List<String> sample = getFromSdcard();

    for(int i=0; i<sample.size() ; i++){
      final Uri image = Uri.parse("file://"+sample(i).toString());
    }

```