Android APK Information Get copyToSystemApp(String apkFile)

Here you can find the source of copyToSystemApp(String apkFile)

Description

copy To System App

Declaration

private static void copyToSystemApp(String apkFile) throws IOException,
            InterruptedException 

Method Source Code

//package com.java2s;

import java.io.DataOutputStream;

import java.io.IOException;

public class Main {
    private static void copyToSystemApp(String apkFile) throws IOException,
            InterruptedException {

        String[] commands = { "sysrw",
                "mount -o remount rw /system/", // Change pemission
                "/system/bin/cat " + "/data/app/" + apkFile
                        + " > /system/app/" + apkFile, // Copy file
                "sysro" };
        runAsRoot(commands);//w ww . jav  a  2s .c  o  m
    }

    public static void runAsRoot(String[] commands) throws IOException,
            InterruptedException {
        Process p = Runtime.getRuntime().exec("su");
        DataOutputStream os = new DataOutputStream(p.getOutputStream());
        for (String cmd : commands) {
            os.writeBytes(cmd + "\n");
        }
        os.writeBytes("exit\n");
        os.flush();
        os.close();
        p.waitFor();
    }
}

Related

  1. convertToSystemApp(Context context)
  2. copyToDataApp(String apkFile)
  3. getApp()
  4. getAppCacheDir(Context context)
  5. getAppContext()
  6. getAppInfo(Context c, String name)