Simple Android file search and simple Android file search
Today, we need to start searching for images in various small folders from large files. Then we can use simple recursion (the efficiency problem is not considered for the time being ).
Private ArrayList <String> readnewlist (String path) {File file = new File (path); File [] files = file. listFiles (); for (int I = 0; I <files. length; I ++) {if (files [I]. isDirectory () {String s = path + "/" + files [I]. getName (); readnewlist (s);} else if (files [I]. getName (). lastIndexOf (". ")> 0 & files [I]. getName (). substring (files [I]. getName (). lastIndexOf (". ") + 1, files [I]. getName (). length ()). equals ("jpg") {arraylist. add (files [I]. getPath () ;}return arraylist ;}
The only thing to note is that the arraylist variable needs to be globally defined or it is null.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.