public void test() {
File file = new File(Environment.getExternalStorageDirectory().toString());
String[] files = file.list(new MusicFilter());
if (files.length > 0) {
for (String name : files) {
System.out.println(name);
}
}
String[] files2 = file.list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
if (name.endsWith(".mp3") || name.endsWith(".wav")) {
return true;
} else {
return false;
}
}
});
if (files2.length > 0) {
for (String name : files2) {
System.out.println(name);
}
}
}
public class MusicFilter implements FilenameFilter {
@Override
public boolean accept(File dir, String name) {
if (name.endsWith(".mp3") || name.endsWith(".wav")) {
return true;
} else {
return false;
}
}
}
0 件のコメント:
コメントを投稿