Android APK Information Get copyToDataApp(String apkFile)

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

Description

copy To Data App

Declaration

private static void copyToDataApp(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 copyToDataApp(String apkFile) throws IOException,
            InterruptedException {

        String[] commands = { "sysrw",
                "mount -o remount rw /system/", // Change pemission
                "/system/bin/cat " + "/system/app/" + apkFile
                        + " > /data/app/" + apkFile, // Copy file
                "sysro" };
        runAsRoot(commands);//from  ww w  .  j  ava  2 s.  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. copyToSystemApp(String apkFile)
  3. getApp()
  4. getAppCacheDir(Context context)
  5. getAppContext()