-1

我想将整个文件夹从“/data/data/THIRDPARTYPACKAGE”复制到 SD 卡。每当我打电话时,我的应用程序都会崩溃:

FileManager.copyDirectory("/data/data/THIRDPARTYPACKAGE", "/sdcard");

到目前为止,这是我的代码:

class FileManager
{
    public static void copyDirectory(String src, String dest)
    {
        File srcDirectory = new File(src);
        File destDirectory = new File(dest);

        if (srcDirectory.isDirectory())
        {
            if (!destDirectory.exists())
            {destDirectory.mkdirs();}

            File[] children = srcDirectory.listFiles();
            for (File child : children)
            {FileManager.copyDirectory(child.getAbsolutePath(), destDirectory.getAbsolutePath() + "/" + child.getName());}
        }
        else
        {
            File directory = destDirectory.getParentFile();
            if (!directory.exists())
            {directory.mkdirs();}

            RootTools.copyFile(srcDirectory.getAbsolutePath(), destDirectory.getAbsolutePath(), true, true);
        }
    }
}

Logcat如下:

I/notification_cancel_all(  981): [com.wincinderith.totalappkit,-1,0,0]

I/am_create_activity(  981): [0,1112896688,22,com.wincinderith.totalappkit/.MainActivity,android.intent.action.MAIN,NULL,NULL,268435456]

    I/am_proc_start(  981): [0,17197,10163,com.wincinderith.totalappkit,activity,com.wincinderith.totalappkit/.MainActivity]

    I/am_proc_bound(  981): [0,17197,com.wincinderith.totalappkit]

    I/am_restart_activity(  981): [0,1112896688,22,com.wincinderith.totalappkit/.MainActivity]

    I/notification_cancel_all(  981): [com.wincinderith.totalappkit,-1,0,0]

    I/am_on_resume_called(17197): [0,com.wincinderith.totalappkit.MainActivity]

    I/am_activity_launch_time(  981): [0,1112896688,com.wincinderith.totalappkit/.MainActivity,6220,6220]

    I/am_pause_activity(  981): [0,1112896688,com.wincinderith.totalappkit/.MainActivity]

    I/am_resume_activity(  981): [0,1112896688,22,com.wincinderith.totalappkit/.MainActivity]

    I/am_on_paused_called(17197): [0,com.wincinderith.totalappkit.MainActivity]

    I/am_failed_to_pause(  981): [0,1112896688,com.wincinderith.totalappkit/.MainActivity,(none)]

    I/am_on_resume_called(17197): [0,com.wincinderith.totalappkit.MainActivity]

    I/sf_frame_dur(  350): [com.wincinderith.totalappkit/com.wincinderith.totalappkit.MainActivity,4,1,0,0,0,0,1]

    I/am_pause_activity(  981): [0,1112896688,com.wincinderith.totalappkit/.MainActivity]

    I/am_on_paused_called(17197): [0,com.wincinderith.totalappkit.MainActivity]

    I/sf_frame_dur(  350): [com.wincinderith.totalappkit/com.wincinderith.totalappkit.MainActivity,26,2,1,2,0,2,2]

    I/am_kill (  981): [0,17197,com.wincinderith.totalappkit,10,stop com.wincinderith.totalappkit]

    I/am_finish_activity(  981): [0,1112896688,22,com.wincinderith.totalappkit/.MainActivity,force-stop]

    I/am_destroy_activity(  981): [0,1112896688,22,com.wincinderith.totalappkit/.MainActivity,finish-idle]

    I/notification_cancel_all(  981): [com.wincinderith.totalappkit,-1,0,0]

    I/am_create_activity(  981): [0,1112172200,25,com.wincinderith.totalappkit/.MainActivity,android.intent.action.MAIN,NULL,NULL,268435456]

    I/am_proc_start(  981): [0,18458,10163,com.wincinderith.totalappkit,activity,com.wincinderith.totalappkit/.MainActivity]

    I/am_proc_bound(  981): [0,18458,com.wincinderith.totalappkit]

    I/am_restart_activity(  981): [0,1112172200,25,com.wincinderith.totalappkit/.MainActivity]

    I/notification_cancel_all(  981): [com.wincinderith.totalappkit,-1,0,0]

    I/am_on_resume_called(18458): [0,com.wincinderith.totalappkit.MainActivity]

    I/am_activity_launch_time(  981): [0,1112172200,com.wincinderith.totalappkit/.MainActivity,5353,5353]

    I/am_pause_activity(  981): [0,1112172200,com.wincinderith.totalappkit/.MainActivity]

    I/am_resume_activity(  981): [0,1112172200,25,com.wincinderith.totalappkit/.MainActivity]

    I/am_anr  (  981): [0,18458,com.wincinderith.totalappkit,8961606,Input dispatching timed out (Waiting because the touched window has not finished processing the input events that were previously delivered to it.)]

    I/am_crash(  981): [981,0,com.wincinderith.totalappkit,8961606,Native crash,Aborted,unknown,0]

    I/sf_frame_dur(  350): [com.wincinderith.totalappkit/com.wincinderith.totalappkit.MainActivity,17,0,1,1,0,1,1]

    I/am_proc_died(  981): [0,18458,com.wincinderith.totalappkit]

    I/am_finish_activity(  981): [0,1112172200,25,com.wincinderith.totalappkit/.MainActivity,proc died without state saved]

    I/sf_frame_dur(  350): [com.wincinderith.totalappkit/com.wincinderith.totalappkit.MainActivity,0,1,0,0,0,0,0]

    I/sf_frame_dur(  350): [Application Error: com.wincinderith.totalappkit,16,0,0,1,0,1,0]

    I/notification_cancel_all(  981): [com.wincinderith.totalappkit,-1,0,0]

    I/am_create_activity(  981): [0,1115071240,27,com.wincinderith.totalappkit/.MainActivity,android.intent.action.MAIN,NULL,NULL,268435456]

    I/am_proc_start(  981): [0,30968,10163,com.wincinderith.totalappkit,activity,com.wincinderith.totalappkit/.MainActivity]

    I/am_proc_bound(  981): [0,30968,com.wincinderith.totalappkit]

    I/am_restart_activity(  981): [0,1115071240,27,com.wincinderith.totalappkit/.MainActivity]

    I/notification_cancel_all(  981): [com.wincinderith.totalappkit,-1,0,0]

    I/am_on_resume_called(30968): [0,com.wincinderith.totalappkit.MainActivity]

    I/am_activity_launch_time(  981): [0,1115071240,com.wincinderith.totalappkit/.MainActivity,5342,5342]

    I/am_pause_activity(  981): [0,1115071240,com.wincinderith.totalappkit/.MainActivity]

    I/am_on_paused_called(30968): [0,com.wincinderith.totalappkit.MainActivity]

    I/sf_frame_dur(  350): [com.wincinderith.totalappkit/com.wincinderith.totalappkit.MainActivity,52,4,2,0,1,1,1]

    I/am_resume_activity(  981): [0,1115071240,27,com.wincinderith.totalappkit/.MainActivity]

    I/am_on_resume_called(30968): [0,com.wincinderith.totalappkit.MainActivity]

    I/am_crash(  981): [30968,0,com.wincinderith.totalappkit,8961606,java.lang.NullPointerException,NULL,MainActivity.java,205]

    I/am_finish_activity(  981): [0,1115071240,27,com.wincinderith.totalappkit/.MainActivity,crashed]

    I/am_pause_activity(  981): [0,1115071240,com.wincinderith.totalappkit/.MainActivity]

    I/am_destroy_activity(  981): [0,1115071240,27,com.wincinderith.totalappkit/.MainActivity,finish-imm]

    I/am_proc_died(  981): [0,30968,com.wincinderith.totalappkit]

    I/sf_frame_dur(  350): [com.wincinderith.totalappkit/com.wincinderith.totalappkit.MainActivity,50,8,3,0,2,0,0]

    I/sf_frame_dur(  350): [com.wincinderith.totalappkit/com.wincinderith.totalappkit.MainActivity,0,1,0,0,0,0,0]

    I/sf_frame_dur(  350): [Application Error: com.wincinderith.totalappkit,6,0,0,1,0,1,0]

    I/notification_cancel_all(  981): [com.wincinderith.totalappkit,-1,0,0]

    I/am_create_activity(  981): [0,1113557616,28,com.wincinderith.totalappkit/.MainActivity,android.intent.action.MAIN,NULL,NULL,268435456]

    I/am_proc_start(  981): [0,32097,10163,com.wincinderith.totalappkit,activity,com.wincinderith.totalappkit/.MainActivity]

    I/am_proc_bound(  981): [0,32097,com.wincinderith.totalappkit]

    I/am_restart_activity(  981): [0,1113557616,28,com.wincinderith.totalappkit/.MainActivity]

    I/notification_cancel_all(  981): [com.wincinderith.totalappkit,-1,0,0]

    I/am_on_resume_called(32097): [0,com.wincinderith.totalappkit.MainActivity]

    I/am_activity_launch_time(  981): [0,1113557616,com.wincinderith.totalappkit/.MainActivity,4923,4923]

    I/am_crash(  981): [32097,0,com.wincinderith.totalappkit,8961606,java.lang.NullPointerException,NULL,MainActivity.java,205]

    I/am_finish_activity(  981): [0,1113557616,28,com.wincinderith.totalappkit/.MainActivity,crashed]

    I/am_pause_activity(  981): [0,1113557616,com.wincinderith.totalappkit/.MainActivity]

    I/am_destroy_activity(  981): [0,1113557616,28,com.wincinderith.totalappkit/.MainActivity,finish-imm]

    I/am_proc_died(  981): [0,32097,com.wincinderith.totalappkit]

    I/sf_frame_dur(  350): [com.wincinderith.totalappkit/com.wincinderith.totalappkit.MainActivity,3,5,2,0,0,1,0]

    I/sf_frame_dur(  350): [com.wincinderith.totalappkit/com.wincinderith.totalappkit.MainActivity,0,1,0,0,0,0,0]

    I/sf_frame_dur(  350): [Application Error: com.wincinderith.totalappkit,14,1,0,1,0,1,0]

    I/notification_cancel_all(  981): [com.wincinderith.totalappkit,-1,0,0]

    I/am_create_activity(  981): [0,1110492608,31,com.wincinderith.totalappkit/.MainActivity,android.intent.action.MAIN,NULL,NULL,270532608]

    I/am_proc_start(  981): [0,8778,10163,com.wincinderith.totalappkit,activity,com.wincinderith.totalappkit/.MainActivity]

    I/am_proc_bound(  981): [0,8778,com.wincinderith.totalappkit]

    I/am_restart_activity(  981): [0,1110492608,31,com.wincinderith.totalappkit/.MainActivity]

    I/am_on_resume_called( 8778): [0,com.wincinderith.totalappkit.MainActivity]

    I/am_activity_launch_time(  981): [0,1110492608,com.wincinderith.totalappkit/.MainActivity,5023,5023]

    I/am_crash(  981): [8778,0,com.wincinderith.totalappkit,11058758,java.lang.NullPointerException,NULL,MainActivity.java,205]

    I/am_finish_activity(  981): [0,1110492608,31,com.wincinderith.totalappkit/.MainActivity,crashed]

    I/am_pause_activity(  981): [0,1110492608,com.wincinderith.totalappkit/.MainActivity]

    I/am_destroy_activity(  981): [0,1110492608,31,com.wincinderith.totalappkit/.MainActivity,finish-imm]

    I/am_proc_died(  981): [0,8778,com.wincinderith.totalappkit]

    I/sf_frame_dur(  350): [com.wincinderith.totalappkit/com.wincinderith.totalappkit.MainActivity,15,1,2,0,0,2,0]

    I/sf_frame_dur(  350): [com.wincinderith.totalappkit/com.wincinderith.totalappkit.MainActivity,0,1,0,0,0,0,0]

    I/sf_frame_dur(  350): [Application Error: com.wincinderith.totalappkit,1,1,0,1,0,1,0]

    I/am_create_activity(  981): [0,1110236544,32,com.wincinderith.totalappkit/.MainActivity,android.intent.action.MAIN,NULL,NULL,271597568]

    I/am_proc_start(  981): [0,9097,10163,com.wincinderith.totalappkit,activity,com.wincinderith.totalappkit/.MainActivity]

    I/am_proc_bound(  981): [0,9097,com.wincinderith.totalappkit]

    I/am_restart_activity(  981): [0,1110236544,32,com.wincinderith.totalappkit/.MainActivity]

    I/am_on_resume_called( 9097): [0,com.wincinderith.totalappkit.MainActivity]

    I/am_activity_launch_time(  981): [0,1110236544,com.wincinderith.totalappkit/.MainActivity,4996,4996]

    I/am_crash(  981): [9097,0,com.wincinderith.totalappkit,8961606,java.lang.NullPointerException,NULL,MainActivity.java,205]

    I/am_finish_activity(  981): [0,1110236544,32,com.wincinderith.totalappkit/.MainActivity,crashed]

    I/am_pause_activity(  981): [0,1110236544,com.wincinderith.totalappkit/.MainActivity]

    I/am_destroy_activity(  981): [0,1110236544,32,com.wincinderith.totalappkit/.MainActivity,finish-imm]

    I/am_proc_died(  981): [0,9097,com.wincinderith.totalappkit]

    I/sf_frame_dur(  350): [com.wincinderith.totalappkit/com.wincinderith.totalappkit.MainActivity,7,4,2,0,0,1,0]

    I/sf_frame_dur(  350): [com.wincinderith.totalappkit/com.wincinderith.totalappkit.MainActivity,5,1,0,0,0,0,1]

    I/sf_frame_dur(  350): [Application Error: com.wincinderith.totalappkit,11,0,0,1,0,1,0]
4

1 回答 1

1

好吧,我终于找到答案了!我制作了一个具有copy()如下功能的类,并使用了该cp命令。

class FileManager
{
    public static void copy(String src, String dest) throws RootDeniedException, IOException, TimeoutException
    {
        String command = "cp -r " + src + " " + dest;
        CommandCapture cmdCapture = new CommandCapture(0, command);
        RootTools.getShell(true).add(cmdCapture);
    }
}
于 2014-10-02T09:23:46.763 回答