嘿,在为2.3.3构建一个android应用程序时,我得到了以下错误:
我试着访问这些文件:
private static final String src_msg = "/data/data/com.whatsapp/databases/msgstore.db";
private static final String src_wa = "/data/data/com.whatsapp/databases/wa.db";
我之前执行了su:
Process process = Runtime.getRuntime().exec("su");
我尝试通过cp命令->将文件复制到sdcard没有成功我尝试通过new File(src_msg).exists()
->检查文件是否存在没有成功
我在清单中使用以下权限:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
这里还遗漏了什么?弹出允许root的弹出窗口,并已被接受。
发布于 2012-09-07 21:50:28
试试这个:(感谢ramdroid )
private boolean run(boolean runAsRoot, String cmd) {
String shell = runAsRoot ? "su" : "sh";
int exitCode = 255;
Process p;
try {
p = Runtime.getRuntime().exec(shell);
DataOutputStream os = new DataOutputStream(p.getOutputStream());
os.writeBytes(cmd + "\n");
os.flush();
os.writeBytes("exit\n");
os.flush();
exitCode = p.waitFor();
} catch (IOException e1) {
Log.e("Exception", e1.toString());
} catch (InterruptedException e) {
Log.e("Exception", e.toString());
}
return (exitCode != 255);
}
public boolean copyFile() {
return run(true, "busybox cp /data/FILE TO COPY space DRECTORY TO COPY");
}
仅将YOUR_DIRECTORY和目录更改为COPYto所需的内容。
https://stackoverflow.com/questions/12319301
复制相似问题