File.list () returns null for the directory

When executing code

File path = new File("/data");
boolean isDir = path.isDirectory();
//isDir is true
String[] fList = path.list();
//fList == null!

on Android 2.3 emulator, the list of files 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 is wrong here?

+5
source share
1 answer

You cannot access /datadir because you do not have root access. Without root privileges, you can only access the external storage and the application directory on the internal storage. Have a look at this answer: fooobar.com/questions/43015 / ...

+3
source

All Articles