Я работаю над приложением для сканирования файлов и очищаю кеш, это сбой при работе.мое приложение имеет чистый кэш, такой как приложение boost, деинсталлирует apk из приложения Ram boost и т.д. ........
private void travelPath(File root, int level) {
if (root == null || !root.exists() || level > SCAN_LEVEL) {
return;
}
File[] lists = root.listFiles();
for (File file : lists) {
if (file.isFile()) {
String name = file.getName();
JunkInfo info = null;
if (name.endsWith(".apk")) {
info = new JunkInfo();
info.mSize = file.length();
info.name = name;
info.mPath = file.getAbsolutePath();
info.mIsChild = false;
info.mIsVisible = true;
mApkInfo.mChildren.add(info);
mApkInfo.mSize += info.mSize;
} else if (name.endsWith(".log")) {
info = new JunkInfo();
info.mSize = file.length();
info.name = name;
info.mPath = file.getAbsolutePath();
info.mIsChild = false;
info.mIsVisible = true;
mLogInfo.mChildren.add(info);
mLogInfo.mSize += info.mSize;
} else if (name.endsWith(".tmp") || name.endsWith(".temp")) {
info = new JunkInfo();
info.mSize = file.length();
info.name = name;
info.mPath = file.getAbsolutePath();
info.mIsChild = false;
info.mIsVisible = true;
mTmpInfo.mChildren.add(info);
mTmpInfo.mSize += info.mSize;
}
if (info != null) {
mCallback.onProgress(info);
}
} else {
if (level < SCAN_LEVEL) {
travelPath(file, level + 1);
}
}
}
}
и ошибка LogCat:
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:353)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.NullPointerException: Attempt to get length of null array
at com.example.dell.testnew.custom.OverallScanTask.travelPath(OverallScanTask.java:35)
at com.example.dell.testnew.custom.OverallScanTask.doInBackground(OverallScanTask.java:85)
at com.example.dell.testnew.custom.OverallScanTask.doInBackground(OverallScanTask.java:15)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.NullPointerException: Attempt to get length of null array
at com.example.dell.testnew.custom.OverallScanTask.travelPath(OverallScanTask.java:35)
at com.example.dell.testnew.custom.OverallScanTask.doInBackground(OverallScanTask.java:85)
at com.example.dell.testnew.custom.OverallScanTask.doInBackground(OverallScanTask.java:15)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
здесь появляется ошибказа цикл для сканера файлов
Заранее спасибо за помощь, я буду признателен за ваш ответ