Access to /data/data/com.whatsapp

13,253

Try that: (Thanks to 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");
} 

Change only YOUR_DIRECTORY and DIRECTORY TO COPYto the needed ones.

Share:
13,253
Admin
Author by

Admin

Updated on June 05, 2022

Comments

  • Admin
    Admin almost 2 years

    Hy, while building an android application for 2.3.3 I got the following error:

    I tried to access the files:

    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";
    

    I do su before:

    Process process = Runtime.getRuntime().exec("su");
    

    I tried to copy the files to sdcard via cp command -> no success I tried to check if the files exists via new File(src_msg).exists() -> no success

    I use the following permissions in manifest:

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    

    what else is missing here? the popup to allow root comes up and has been accepted.

  • vikki
    vikki over 11 years
    you just copy-pasted the answer, and your cp command is infact wrong
  • tolgap
    tolgap over 11 years
    You do know you have to copy it to a directory your own right? Milos doesn't know which directory you want so he left that part out.
  • Milos Cuculovic
    Milos Cuculovic over 11 years
    @vikki, yes, that's why I said thankd to ramdroid.I dont know which directory he would like to use, this part should be customized.
  • vikki
    vikki over 11 years
    @tolgap doesn't make the command right does it? when answering a question you don't know everything about OP's situation, you leave template code, but it should at least be valid code.
  • vikki
    vikki over 11 years
    Nope! see how ramdroid did it, first is the file you want to copy space and then the dir in which to copy it.... which is why you shouldn't have copied the answer in the 1st place.
  • Milos Cuculovic
    Milos Cuculovic over 11 years
    This was the YOUR DIRECTORY but ok, I reedited my answer, happy now ? :)