How to read only text file from sdcard in android?
HI...
I am New To Android, My requirement is to display Total SDcard files in Listview , in that i w开发者_JAVA技巧ant to read only TextFiles. Can anyone HelpMe.... Thanks in advance...
You should check out FilenameFilter.
Something like this:
FilenameFilter filter = new FilenameFilter() {
@Override
public boolean accept(File dir, String filename) {
return (filename.endsWith(".txt"));
}
};
And:
String[] list = dir.list(filter);
There you go! :)
精彩评论