Android: how can execute a chmod on rooted devides

后端 未结 3 1099
余生分开走
余生分开走 2021-01-07 02:58

I would execute a command on my rooted Android 2.1 device

String path = \"/data/data/com.android.providers.settings/databases/settings.db\"; Runtime

3条回答
  •  天命终不由人
    2021-01-07 03:12

    You need to get the runtime as the root user first. There is a nice ShellInterface class that you can use from the MarketEnabler source available on Google Code. Though keep in mind this source code is released under the GPL.

    Essentially what you need to do is determine where your su command is and create a kind of shell using an input stream and output stream for STDIN and STDOUT. With these you can then push your commands to your "terminal". When you are done all your commands, flush your buffer and then wait for the Runtime to complete. Once it is completed, you can then close your runtime interface.

    Then take a look at the file you have tried creating/modifying/etc to see if everything worked properly.

提交回复
热议问题