How to retrive file from sd card(Recursive Methods)
public void walk(String path) {
File f = new File(path);
File[] fileList = f.listFiles();
for (File file : fileList) {
try {
if (file.isDirectory()) {
walk(file.getAbsolutePath());
System.out.println("Dir: " + file.getAbsoluteFile());
} else {
System.out.println("File: " + file.getAbsoluteFile());
}
} catch (Exception e) {
System.out.println(e.getMessage());
Log.i("Information", e.getMessage());
}
}
}
File f = new File(path);
File[] fileList = f.listFiles();
for (File file : fileList) {
try {
if (file.isDirectory()) {
walk(file.getAbsolutePath());
System.out.println("Dir: " + file.getAbsoluteFile());
} else {
System.out.println("File: " + file.getAbsoluteFile());
}
} catch (Exception e) {
System.out.println(e.getMessage());
Log.i("Information", e.getMessage());
}
}
}
No comments:
Post a Comment
Must Comment