0

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?

FilipK
  • 626
  • 1
  • 4
  • 13
  • http://stackoverflow.com/questions/2507960/does-android-keep-the-apk-files-if-so-where – Padma Kumar Jan 09 '12 at 15:42
  • @Padma Kumar - at first I was about to answer "I know where does Android store APKs and I know that some of my APK files are there." But then I read further an answer by [hackbod](http://stackoverflow.com/a/2509816/626602) mentioning that a standard process can't list contents of /data/app and only read a specific APK stored there. – FilipK Jan 10 '12 at 13:09

1 Answers1

1

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.

Gangnus
  • 24,044
  • 16
  • 90
  • 149
  • Typical installation of an app results in the application's APK file being stored in /data/app. I am sure that at minimum the application containing the code fragment I posted is there. – FilipK Jan 10 '12 at 13:04
  • If you are rooted, simply `chmod 775 /data/data` – Renate Jun 29 '12 at 12:54
  • Oops, same thing, same problem, but I meant `chmod 775 /data/app` – Renate Jun 29 '12 at 13:29