Why video URI is giving Invalid column?

Hi,
I am trying to read video file detail using below code

val resolver = context.contentResolver
val cursor = resolver.query(uri, PROJECTION, null, null, SORT_ORDER);

This is working fine fro android emulator but, I tried to same code on Ssamsung Galaxy M40, with URI

content://media/external/video/media/22

Its throwing below exception:

java.lang.IllegalArgumentException: Invalid column vnd.android.cursor.dir/video

How are you declaring PROJECTION and SORT_ORDER?

Here is the way, Its working in android emulator:

private val PROJECTION =
        arrayOf(
                MediaStore.Video.Media.CONTENT_TYPE,
                MediaStore.Video.Media.TITLE,
                MediaStore.Video.Media.DISPLAY_NAME,
                MediaStore.Video.Media.DURATION,
                MediaStore.Video.Media.SIZE,
                MediaStore.Video.Media.DESCRIPTION
        )
private const val SORT_ORDER = MediaStore.Video.Media.DATE_ADDED

OK. I cannot explain that error. The error suggests that Samsung is trying to treat a MIME type (vnd.android.cursor.dir/video) as the name of a column. You might try removing CONTENT_TYPE from PROJECTION and see if the query runs. If it does, you can use getType() on ContentResolver to get the MIME type.