Reputation: 2619
I want to make an application installed at android rooted device as a system app from java application.. for that I have to execute following commands
adb remount
adb shell
su
cd /data/app/
ls com.mypackage *
then have to check if app with this package name is installed after that have to execute following commands
mv com.mypackage.apk /system/app/com.mypackage.apk
exit
exit
adb reboot
any Idea how I can achieve this?
Upvotes: 0
Views: 2143
Reputation: 4821
Try using process builder in your application to run the adb commands.
Example
String[] command = {"ls", "-s"}; // Mention your list of commands here
StringBuilder cmdReturn = new StringBuilder();
try {
ProcessBuilder processBuilder = new ProcessBuilder(command);
Process process = processBuilder.start();
InputStream inputStream = process.getInputStream();
int c;
while ((c = inputStream.read()) != -1) {
cmdReturn.append((char) c);
}
prompt.setText(cmdReturn.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Upvotes: 1