Search code examples
androidio

how to navigate throught a directory in the internal storage


I already saw this question of creating a folder inside the internal storage Creating Folder in Internal memory but how can I create a subfolder and get the list of files and folders stored inside that folder Here is a thing I tried

val root=getDir("fold", Context.MODE_PRIVATE)
        root.mkdirs()
        val root1=getDir("fold\\a", Context.MODE_PRIVATE)
        root1.mkdirs()
        val root2=getDirs("fold\\b", Context.MODE_PRIVATE)
        root2.mkdir()
val x=root.listFiles().size
val y=root.list().size

but both the values of x and y are 0 which means either the directories are not created or (list or listFiles) are not used to retrieve the files and folders inside a directory

Thanks in advance


Solution

  • I have found the solution.... to create a folder and keep it kept persistence I should use the FILE class instead.. like the following val root=File(parentFile,fold);root.mkdirs() then every thing will work well