Copy folders in /data/data to sdcard & vice-versa

后端 未结 1 1975
感情败类
感情败类 2020-12-18 09:33

I have a problem when I try to copy folders inside /data/data to SDcard.

I have my phone rooted.

I request Superuser permissions in my app with:

<         


        
相关标签:
1条回答
  • 2020-12-18 09:41

    At the end I got it!!!!

    I use the SuperUser process with the cp command to copy the files and folders.

    I hope you find it helpful.

    String comando = "cp -r /data/data/sourcefolder /sdcard/targetfolder";
    Process suProcess = Runtime.getRuntime().exec("su");
    DataOutputStream os = new DataOutputStream(suProcess.getOutputStream());
    os.writeBytes(comando + "\n");
    os.flush();
    os.writeBytes("exit\n");
    os.flush();
    try
    {
     int suProcessRetval = suProcess.waitFor();
     if (255 != suProcessRetval)
     {
      // Acceso Root concedido
      retval = true;
     }else
     {
      // Acceso Root denegado
      retval = false;
     }
    }
    catch (Exception ex)
    {
     Log.w("Error ejecutando el comando Root", ex);
    }
    

    Thank you very much to all the people of this forum and for all the help which you offer!!

    0 讨论(0)
提交回复
热议问题