public static List<String> musicPaths = null;
public String getSDPath()
{
File sdDir = null;
boolean sdCardExist = Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED); // 判断sd卡是否存在
if (sdCardExist)
{
sdDir = Environment.getExternalStorageDirectory();
}
return sdDir != null ? sdDir.toString() : "";
}
private List<String> getMusicList()
{
musicPaths.clear();
try
{
File file = new File(getSDPath());
File[] files = file.listFiles();
for(File theFile : files)
{
if(theFile.isDirectory())
{
musicPaths.add(theFile.getPath());
}
}
for(File theFile : files)
{
if(theFile.isFile())
{
if(matchMusicFile(theFile.getPath()))
{
musicPaths.add(theFile.getPath());
}
}
}
}
catch (Exception e)
{
return main.musicPaths;
}
return main.musicPaths;
}