listFiles() nullpointerexception when called

I’m calling listFiles() with read and write permissions granted; on Android 11 but it gives a NullPointerException error even tho the path is correct (I got the path from a ActivityResultContracts.OpenDocumentTree() Activity) and stored as variable like so folderPath = it.path var mydir = File(folderPath) files = mydir.listFiles()!! it results in NullPointerException still even tho… Read More listFiles() nullpointerexception when called