apk が /data/app にパッケージの名前 (および最後に「-1」) で保存されていることを知っています。
root 以外の電話では、/data/app に含まれるファイルをリスト (ls) することはできませんが、ファイル名がわからないので、root がなくても /data/app から /mnt/sdcard/whereeveriwant/ に apk をコピーできます許可。
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 は別の名前を持っていますか? それともフォワードロックですか?
これはリサーチクエスチョンであり、実際の使用は意図されていません。