我正在尝试将一些文件从 \data\data*\cache\ 中的目录复制到外部存储器中的文件夹中。我有 root 访问权限,并且有 chmod 777 应用程序文件夹,所以可以访问这些文件,但是当尝试使用 Apache IO 或输入/输出流复制这些文件时,我得到“文件不存在”或“无法访问这个目录”。
这是我的 Asynctask 与 Apache 和我的 logcat。任何帮助都会很棒,谢谢。
private class CopyandList extends AsyncTask<String, Void, Void>{
ProgressDialog SnapDialog= new ProgressDialog(MainActivity.this);
@Override
protected void onPreExecute() {
SnapDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
SnapDialog.setTitle("Copying...");
SnapDialog.setMessage("Please Wait");
SnapDialog.setIndeterminate(true);
SnapDialog.setCancelable(false);
SnapDialog.show();
}
@Override
protected Void doInBackground(String... arg0) {
File file = new File(directory);
File list[] = file.listFiles();
for( int i=0; i< list.length; i++){
File X = new File(directory + list[i].getAbsolutePath());
File Y = new File(destination.getAbsolutePath());
try {
FileUtils.copyFileToDirectory(X, Y, true);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return null;
}
protected void onPostExecute(Void result) {
if(SnapDialog.isShowing()){
SnapDialog.dismiss();
}
File file;
file = new File(Snapdes);
File list[] = file.listFiles();
ListView ListView = (ListView) findViewById(R.id.SnapList);
List<String> SnapList;
SnapList = new ArrayList<String>();
for( int i=0; i< list.length; i++){
SnapList.add( list[i].getName() );
}
ArrayAdapter<String> adapter = new ArrayAdapter<String> (MainActivity.this, android.R.layout.simple_list_item_1, android.R.id.text1, SnapList);
ListView.setAdapter(adapter);
}
}
05-31 15:23:47.060: W/System.err(19176): java.io.FileNotFoundException: Source '/data/data/com.snapchat.android/cache/received_image_snaps/data/data/com.snapchat.android/cache/received_image_snaps/h1a81hurcs00h1370007662341.jpg.nomedia' does not exist
05-31 15:23:47.060: W/System.err(19176): at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:1074)
05-31 15:23:47.060: W/System.err(19176): at org.apache.commons.io.FileUtils.copyFileToDirectory(FileUtils.java:1013)
05-31 15:23:47.060: W/System.err(19176): at org.apache.commons.io.FileUtils.copyFileToDirectory(FileUtils.java:977)
05-31 15:23:47.060: W/System.err(19176): at com.itsallwhite.sneakysnapper.MainActivity$CopyandList.doInBackground(MainActivity.java:152)
05-31 15:23:47.060: W/System.err(19176): at com.itsallwhite.sneakysnapper.MainActivity$CopyandList.doInBackground(MainActivity.java:1)
05-31 15:23:47.060: W/System.err(19176): at android.os.AsyncTask$2.call(AsyncTask.java:287)
05-31 15:23:47.060: W/System.err(19176): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
05-31 15:23:47.060: W/System.err(19176): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
05-31 15:23:47.060: W/System.err(19176): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
05-31 15:23:47.060: W/System.err(19176): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
05-31 15:23:47.060: W/System.err(19176): at java.lang.Thread.run(Thread.java:856)
05-31 15:23:47.060: W/System.err(19176): java.io.FileNotFoundException: Source '/data/data/com.snapchat.android/cache/received_image_snaps/data/data/com.snapchat.android/cache/received_image_snaps/h1a81hurcs00h1370007662458.jpg.nomedia' does not exist
05-31 15:23:47.060: W/System.err(19176): at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:1074)
05-31 15:23:47.065: W/System.err(19176): at org.apache.commons.io.FileUtils.copyFileToDirectory(FileUtils.java:1013)
05-31 15:23:47.065: W/System.err(19176): at org.apache.commons.io.FileUtils.copyFileToDirectory(FileUtils.java:977)
05-31 15:23:47.065: W/System.err(19176): at com.itsallwhite.sneakysnapper.MainActivity$CopyandList.doInBackground(MainActivity.java:152)
05-31 15:23:47.065: W/System.err(19176): at com.itsallwhite.sneakysnapper.MainActivity$CopyandList.doInBackground(MainActivity.java:1)
05-31 15:23:47.065: W/System.err(19176): at android.os.AsyncTask$2.call(AsyncTask.java:287)
05-31 15:23:47.065: W/System.err(19176): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
05-31 15:23:47.075: W/System.err(19176): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
05-31 15:23:47.075: W/System.err(19176): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
05-31 15:23:47.075: W/System.err(19176): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
05-31 15:23:47.075: W/System.err(19176): at java.lang.Thread.run(Thread.java:856)
05-31 15:23:47.075: W/System.err(19176): java.io.FileNotFoundException: Source '/data/data/com.snapchat.android/cache/received_image_snaps/data/data/com.snapchat.android/cache/received_image_snaps/h1a81hurcs00h1370007662469.jpg.nomedia' does not exist
05-31 15:23:47.075: W/System.err(19176): at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:1074)
05-31 15:23:47.080: W/System.err(19176): at org.apache.commons.io.FileUtils.copyFileToDirectory(FileUtils.java:1013)
05-31 15:23:47.080: W/System.err(19176): at org.apache.commons.io.FileUtils.copyFileToDirectory(FileUtils.java:977)
05-31 15:23:47.080: W/System.err(19176): at com.itsallwhite.sneakysnapper.MainActivity$CopyandList.doInBackground(MainActivity.java:152)
05-31 15:23:47.080: W/System.err(19176): at com.itsallwhite.sneakysnapper.MainActivity$CopyandList.doInBackground(MainActivity.java:1)
05-31 15:23:47.080: W/System.err(19176): at android.os.AsyncTask$2.call(AsyncTask.java:287)
05-31 15:23:47.080: W/System.err(19176): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
05-31 15:23:47.080: W/System.err(19176): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
05-31 15:23:47.080: W/System.err(19176): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
05-31 15:23:47.080: W/System.err(19176): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
05-31 15:23:47.080: W/System.err(19176): at java.lang.Thread.run(Thread.java:856)