简体   繁体   English

如何等到具有根访问权限的文件从系统目录复制到外部存储之前

[英]How to wait until file copy from system directory to external storage with root access

i have file from next path: /data/data/com.google.chrome/examplefile.txt , and i wanna copy the file by path: /sdcard/examplefile.txt and perform operations with him, but file size: 7 MB, and it takes time. 我的文件来自下一个路径: /data/data/com.google.chrome/examplefile.txt ,我想按以下路径复制文件: /sdcard/examplefile.txt并与他进行操作,但是文件大小:7 MB,这需要时间。 I wanna copy the file wait until him copies and perform operations with him. 我想复制文件,等到他复制并与他一起执行操作。

I have superuser access (Root), and to copy file from /data/data dir need root access. 我具有超级用户访问权限(Root),并且要从/ data / data目录复制文件需要root访问权限。

Use an AsyncTask to do the job on background: 使用AsyncTask在后台执行作业:

public class CopyFileTask extends AsyncTask <Void, Void, Void> {

    File file;

    public CopyFileTask () {
        file = null;
    }

    @Override
    protected Void doInBackground(Void... voids) {
        //Your code to copy the file here
        file = copyFileMethod();
        return null;
    }

    @Override
    protected void onPostExecute(Void aVoid) {
        //If the file is not null, then that means you copied it
        if(file != null ){
        //Perform here the rest of the operations
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM