3

I'm using chmod command to change file's permission but it's doesn't work in my code and my device is rooted too:

String MyFilePath = "/data/data/MyPkgName/database/com.pocketchange.android.http.AsyncHttpRequestService.db";
CommandCapture command = new CommandCapture(0, "chmod  777 " + "\""+ MyFilePath+ "\"");
RootTools.getShell(true).add(command).waitForFinish();

And when it's execute, the command output is :

Unable to chmod /data/data/MyPkgName/databases/com.pocketchange.android.http.AsyncHttpRequestService.db: No such file or directory

but the file is exist, and when I use this code to change the permission of another file in the database directory its success, so what can I do now.

Mahmoud Jorban
  • 952
  • 4
  • 13
  • 25

2 Answers2

0

Use the chmod command in the ADB shell...

String[] strExec = new String[] 
{ 
       "/system/bin/sh", "-c","/system/bin/chmod 777
};

try {
    Runtime.getRuntime().exec(strExec);
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
Ravi Shinde
  • 17
  • 2
  • 10
0

1.Do RootTools.isAccessGiven() check first, then the system will ask for "Root" permission in the style of Dialog. After permitting the root can you successfully run the root command.
2."\""+ MyFilePath+ "\""=> MyFilePath

Cheng
  • 47
  • 2
  • 6