This is what I did and it works in sdk 29, it will return all files regardless of type.
val uri = MediaStore.Files.getContentUri("external")
val projection = arrayOf(
MediaStore.Images.Media.DATA,
MediaStore.Files.FileColumns.MIME_TYPE,
)
val cursor = this.contentResolver.query(
uri,
projection,
null,
null,
MediaStore.Images.Media.DATE_ADDED + " DESC"
)
But after forced to raise targetSdk to at least 30 (Playstore required), it only returns image/video/audio files, is there any way to solve this problem, or is there any other way to read all files (or at least document files)?