Yes, With old code it won't work. Here i found the solution
    List<Uri> filesList = new ArrayList<>();
    Uri collection;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
        collection = MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL);
    } else {
        collection = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
    }
    String[] projection = new String[]{
            MediaStore.Images.Media._ID,
            MediaStore.Images.Media.DISPLAY_NAME,
            MediaStore.Images.Media.SIZE
    };
    String selection = null;
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {
        selection = MediaStore.Images.Media.BUCKET_DISPLAY_NAME +
                " =? ";
    }
    String[] selectionArgs = new String[]{
            "Your folder name"
    };
    String sortOrder = MediaStore.Images.Media.DISPLAY_NAME + " ASC";
    Cursor cursor = getApplicationContext().getContentResolver().query(
            collection,
            projection,
            selection,
            selectionArgs,
            sortOrder
    );
    if (cursor != null && cursor.moveToFirst()) {
        Log.d("continue", "not null");
    } else {
        Log.d("continue", "null return");
        return;
    }
    // Cache column indices.
    int idColumn = cursor.getColumnIndexOrThrow(MediaStore.Images.Media._ID);
    int nameColumn =
            cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DISPLAY_NAME);
    int sizeColumn = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.SIZE);
    do {
        // Get values of columns for a given Images.
        long id = cursor.getLong(idColumn);
        String name = cursor.getString(nameColumn);
        int size = cursor.getInt(sizeColumn);
        Uri contentUri = ContentUris.withAppendedId(
                MediaStore.Images.Media.EXTERNAL_CONTENT_URI, id);
        Log.d("continue", "path-->" + contentUri);
        filesList.add(contentUri);
        // Stores column values and the contentUri in a local object
        // that represents the media file.
    } while (cursor.moveToNext());
In the above code, I written for images only if you want any other files audio video you need to replace Images with Audio and Video ...etc
Note: if you convert Uri to file or string, then you can't use those files. You will get an error in android 10