I am connected to a Server whose address is 192.168.1.254 and on typing this address in the browser it is showing the list of available folder
i want to display the name of the folder in my android application i have tried the following code but no-luck.
try {
SmbFile test = new SmbFile("smb://192.168.1.254");
SmbFile[] files = test.listFiles();
if (files != null)
for (SmbFile s : files) {
Log.d("debug", s.getName());
}
} catch (SmbException e) {
Log.d("debug", "ERROR");
} catch (Exception e) {
Log.d("debug", "ERROR");
}
which i find here and i also tried
File f = new File("//192.168.1.254");
//also tried with File f = new File("http//192.168.1.254");
File[] files = f.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
// Specify the extentions of files to be included.
return name.endsWith(".bmp") || name.endsWith(".gif");
}
});
// get names of the files
String[] fileNamesArray = null;
for (int indx = 0; indx < files.length(); indx++) {
Log.d("name",files[indx].getName());
}
return fileNamesArray;
from Android : Read Remote Location Folder Name and file Name
No comments:
Post a Comment