title: Working on clear cache App getting Error in an Asynctask method
body: <p>I am working on file scanner App and clear cache it is crash on activity . my application has clear cache like boost application, unstall apk from app Ram boost etc ........</p>
  
  <pre><code> private void travelPath(File root, int level) {
      if (root == null || !root.exists() || level &gt; 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 &lt; SCAN_LEVEL) {
                  travelPath(file, level + 1);
              }
          }
      }
  }
  </code></pre>
  
  <p>and LogCat error is : </p>
  
  <pre><code> 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)
  </code></pre>
  
  <p>getting error here  for loop for a file scanner </p>
  
  <p>Thank you in Advance for help i will appreciate your answer</p>