0

My app access to root for see app data, but it's not working.
I tried this:

private File[] appDataList() {
    Runtime.getRuntime().exec("su");
    File directories = new File("/data/data");
    return directories.listFiles();
}

But it's not working, lisFiles() is empty, content is not visible and root access is requested.

NOTE:
tested on a rooted device.

2 Answers2

0

1) Phone may be non-rooted. You can check this :

> adb shell
> su

2) Check this answer.

Community
  • 1
  • 1
Sergey Shustikov
  • 15,377
  • 12
  • 67
  • 119
0

Call for root privileges doesn't give the root rights to the app, simply create a new process with root rights:
ยท If you want to get the list of files inside /data/data, use the ls command.

if (RootTools.isAccessGiven()) {
    Command myCommand = new Command(0, "ls /data/data") {
        @Override
        public void commandOutput(int i, String line) {
            //line = File/Folder name (not includes the complete path)
            //Do your stuff here using line variable
        }

        @Override
        public void commandTerminated(int i, String s) {

        }

        @Override
        public void commandCompleted(int i, int i1) {

        }
    };
    RootTools.getShell(true).add(myCommand);
}