我们如何从无根设备访问APK文件并将其复制到外部存储?
任何指导都会很棒,
由于
答案 0 :(得分:0)
使用此功能将APK从源包路径复制到您的SD卡(无需root权限)
public static boolean copyFile(String srcFilePath, String destFilePath)
{
boolean success = false;
if(srcFilePath!=null && destFilePath!=null)
{
srcFilePath = srcFilePath.trim();
destFilePath = destFilePath.trim();
if(!srcFilePath.equals("") && !destFilePath.equals("") && !srcFilePath.equals(destFilePath))
{
File srcFile = new File(srcFilePath);
if(srcFile.exists() && srcFile.isFile())
{
try
{
File destFile = new File(destFilePath);
InputStream in = new FileInputStream(srcFile);
OutputStream out = new FileOutputStream(destFile);
// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0)
{
out.write(buf, 0, len);
}
in.close();
out.close();
success = true;
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
}
return success;
}