I'm trying get my app to get the name of every app on the device. The best way I can think of doing this is reading the name of every directory in /data/data/ into a list. I have the following code which works on other directories but not /data/data/.
public void generateDirList() {
File rootDir = new File(currentLocation);
String[] directories = rootDir.list();
subDirs = new ArrayList<String>();
for(String dir : directories)
{
if (new File(currentLocation + File.separator + dir).isDirectory())
{
Log.i(TAG, dir);
subDirs.add(dir);
}
}
}
The problem seems to be that /data isn't being recognized as a directory so rootDir.list()
returns null. My device is rooted and I have the following in my manifest
<uses-permission android:name="android.permission.ACCESS_SUPERUSER" />
What else do I have to do to get this to work ?