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. 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.
Use an AsyncTask to do the job on background:
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
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.