private void getFileList(String dirPath) { LinkedList<File> mDirList = new LinkedList<File>(); File dir = new File(dirPath); mDirList.add(dir); File files[] = null; int count = 0; String filePath = null; File tmp = null; while (!mDirList.isEmpty()) { tmp = mDirList.removeFirst(); //handle files in one directory. files = tmp.listFiles(); if (files == null) continue; for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) mDirList.add(files[i]); else { Log.d(TAG,files[i].getAbsolutePath() + " " + count); count ++; } } } Log.d(TAG,"getFileList finish,file count: " + count); }