I tried to list files in /data/app/ folder on an Android emulator with the following activity, however logcat shows only “No files found in /data/app” no matter if I try File.listFiles() or File.list(). I also tried /data/app/ with no success.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
File dataDir = new File("/data/app");
File[] files = dataDir.listFiles();
if (files == null) {
Log.w("TestActivity", "No files found in /data/app");
} else {
for (File file : files) {
Log.d("TestActivity", "file: " +file.getName());
}
}
}
Am I missing some permission here? Or is simply /data/app empty on an emulator?
As for me, /data/app seems really empty on your emulator. could you show how have you written smth there?
EDIT:
If you want to read applications files there, forget it – it is not allowed. IMHO, to work with applications you need to ask system activities and applications to do it.
So, you can see there ONLY what you have put there BY THAT VERY application. But not that very application itself :-). So, your code has no error. Simply you are awaiting from it too much.