File.list() returns null for directory

android, file-io, java

Solution

You can't access `/data` dir since you don't have root access. Without root privileges you can access just an external storage and your app's dir at internal storage. Look at this answer: https://stackoverflow.com/a/1043722/1037294

Problem

When executing the code ``` File path = new File("/data"); boolean isDir = path.isDirectory(); //isDir is true String[] fList = path.list(); //fList == null! ``` on an Android 2.3 emulator, the file list is null. This seems to contradict the statement from the documentation http://developer.android.com/reference/java/io/File.html#list(): ``` Returns null if this file is not a directory. ``` What's wrong here?

Original source

Related problems