Android Lint 有个关于在代码中硬编码“sdcard”路径的警告,内容为:
不要硬编码(hardcode) “/sdcard/”; 使用 Environment.getExternalStorageDirectory().getPath() 替代sdcard路径
详情参考: http://developer.android.com/guide/topics/data/data-storage.html#filesExternal
具体如下修改:
// private static final String MUSIC_PATH = new String("/sdcard/external_sd/music/"); static String filename = "/external_sd/music/"; private static final String MUSIC_PATH = new String(Environment.getExternalStorageDirectory().getPath()+File.separator+filename);