android - 手机已经安装的软件但apk被手动删除了、请问有办法能找回apk来吗?
高洛峰
高洛峰 2017-04-17 17:18:00
0
2
1037

手机已经安装的软件但apk被手动删除了、请问有办法能找回apk来吗?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(2)
PHPzhong

You can get the APK of the currently installed application

public static String backupApplication(Context context,String packageName, String dest) {
    if (packageName == null || packageName.length() == 0

    || dest == null || dest.length() == 0) {
        return "illegal parameters";
    }
    PackageManager pm = context.getPackageManager();   
    PackageInfo pi = null;
    try {
        pi = pm.getPackageInfo(context.getPackageName(), 0);
    } catch (NameNotFoundException e1) {
        e1.printStackTrace();
    }   
    // check file /data/app/appId-1.apk exists
    Log.i("",""+pi.applicationInfo.sourceDir);
    String apkPath = "/data/app/" + packageName + "-1.apk";

    File apkFile = new File(apkPath);

    if (!apkFile.exists()) {
        apkFile=new File(pi.applicationInfo.sourceDir);
        if(!apkFile.exists()){
            return apkPath + " doesn't exist!";
        }
    }

    FileInputStream in;

    try {
        in = new FileInputStream(apkFile);

    } catch (FileNotFoundException e) {
        e.printStackTrace();
        return e.getMessage();
    }

    // create dest folder if necessary

    int i = dest.lastIndexOf('/');

    if (i != -1) {
        File dirs = new File(dest.substring(0, i));
        dirs.mkdirs();
    }

    // do file copy operation

    byte[] c = new byte[1024];

    int slen;

    FileOutputStream out = null;

    try {
        out = new FileOutputStream(dest);

        while ((slen = in.read(c, 0, c.length)) != -1)
            out.write(c, 0, slen);
    } catch (IOException e) {
        e.printStackTrace();
        return e.getMessage();
    } finally {
        if (out != null)
            try {
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        try {
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return "success";
}
Peter_Zhu

If you are sure that the apk on your phone has been deleted, you can only rely on tools to restore and assemble an apk (the apk itself is a compressed package of programs and resources, and the installation process is a process of decompression and registration).
You can try the apk share software. After running the software, select the app and click backup to restore the apk file and put it in your sdcard.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template