i have a folder in sd card which contains several files.
now i need to get the names of that files.
can anybody have any idea how to get the file names stored in s
/**
* Return list of files from path.
*
* @param path - The path to directory with images
* @return Files name and path all files in a directory, that have ext = "jpeg", "jpg","png", "bmp", "gif"
*/
private List getListOfFiles(String path) {
File files = new File(path);
FileFilter filter = new FileFilter() {
private final List exts = Arrays.asList("jpeg", "jpg",
"png", "bmp", "gif");
@Override
public boolean accept(File pathname) {
String ext;
String path = pathname.getPath();
ext = path.substring(path.lastIndexOf(".") + 1);
return exts.contains(ext);
}
};
final File [] filesFound = files.listFiles(filter);
List list = new ArrayList();
if (filesFound != null && filesFound.length > 0) {
for (File file : filesFound) {
list.add(file.getName());
}
}
return list;
}
This will give you the list of images in a folder. You can modify the code to get all files.