【发布时间】:2013-05-02 12:13:25
【问题描述】:
我知道 apk 以包的名称存储在 /data/app 中(最后是“-1”)。
在非 root 手机上无法列出 (ls) /data/app 中包含的文件,但是由于我知道文件名,我可以将 apk 从 /data/app 复制到 /mnt/sdcard/whereeveriwant/,即使没有root权限。
public static void copyFile(String inputPath, String inputFile, String outputPath) {
InputStream in = null;
OutputStream out = null;
try {
//create output directory if it doesn't exist
File dir = new File (outputPath);
if (!dir.exists()) { dir.mkdirs(); }
in = new FileInputStream(inputPath + inputFile);
out = new FileOutputStream(outputPath + inputFile);
byte[] buffer = new byte[1024];
int read;
while ((read = in.read(buffer)) != -1) {
out.write(buffer, 0, read);
}
in.close();
in = null;
out.flush();
out.close();
out = null;
} catch (FileNotFoundException fnfe1) {
Log.e("copy", fnfe1.getMessage());
} catch (Exception e) {
Log.e("copy", e.getMessage());
}
}
copyFile(
"/data/app/", "com.myawesomeapp.android-1.apk",
Environment.getExternalStorageDirectory() + File.separator + folder + File.separator
);
但是对于某些应用程序(据我所知不是免费应用程序),此方法不起作用。 apk 有不同的名称吗?还是前向锁定?
这是一个研究问题,没有实际用途。
【问题讨论】:
-
试试
/system/app目录。 -
我试过了,但它不起作用。无论如何,我相信 /system/app 仅包含系统应用程序,例如 Contacts.apk 和 Calculator.apk
-
您可以使用 'adb shell pm list package -f' 列出所有已安装的应用程序,包括包名和 apk 位置。
-
我不知道这个命令,它对我帮助很大。付费应用保存在 /mnt/asec/