1

I have a rooted android phone. And Im trying to access /data/app/ folder. Using adb shell it is pretty easy, however I want to access it programmatically.

My android manifest:

...
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:allowBackup="true"
...

And there is a strange thing, I can easily access system/app, but there is no chance to get data or catalog names in data/app.

Some java code:

String data = Environment.getDataDirectory().getPath();       
String system = Environment.getRootDirectory().getPath();

File dir1= new File(system);
File dir2 = new File(data);

String[] ff1 = dir1.list(); // returns bunches of names/catalogs
String[] ff2 = dir2 .list(); // returns null

Where I did mistake? Thanks for help.

Related topics: How to access data/data folder in Android device?

Locky
  • 11
  • 3

1 Answers1

0

If someone has the same mistake, here is the solution:

String path = "/data/app/com.niceapp.hugepackage/base.apk";
File file= new File(path);

There is no posibility to get list of /data/app/ , however you can access the file directly. FYI, this is the way to get all packages:

 List<String > pkg_path = new ArrayList<String>();
 List<PackageInfo> pkginfo_list = pm.getInstalledPackages(PackageManager.GET_ACTIVITIES);
 List<ApplicationInfo> appinfo_list = pm.getInstalledApplications(0);
      for (int x=0; x < pkginfo_list.size(); x++){
            PackageInfo pkginfo = pkginfo_list.get(x);
            pkg_path.add(appinfo_list.get(x).publicSourceDir);  //store package path in array
      }
Locky
  • 11
  • 3