Reputation: 989
my doubt is as simple as title.
I have an X directory where im going to have some images, and i need to send each image of the directory in a mail.
No idea how to check the contest of the directory, and list each file of it so i can send it in a mail.
is it possible?
THX in advance.
Upvotes: 0
Views: 73
Reputation: 8920
How about this:
try {
FileConnection fconn = (FileConnection)Connector.open("file:///SDCard/X");
// If no exception is thrown, then the URI is valid, but the file may or may not exist.
if (fconn.exists() && fconn.isDirectory())
Enumeration list = fconn.list();
while (list.hasMoreElements()) {
String fname = (String)list.nextElement();
//fname could be a file or a sub-directory ...
}
fconn.close();
}
catch (IOException ioe) {
}
Upvotes: 1