我有一个媒体播放器应用程序,视频保存在模拟器的SD卡图像中。现在,我想在Android设备上运行相同的应用程序。
如何将视频从SD卡图像传输到设备存储器?
需要对我的计划进行哪些更改...
代码:
final String MEDIA_PATH = new String("/sdcard/");
//path of sdcard image on emulaotr
public ArrayList<HashMap<String, String>> getPlayList()
{
File home = new File(MEDIA_PATH);
if (home.listFiles(new FileExtensionFilter()).length > 0)
{
for (File file : home.listFiles(new FileExtensionFilter()))
{
HashMap<String, String> song = new HashMap<String,String>();
song.put("songTitle", file.getName().substring(0, (file.getName().length() - 4)));
song.put("songPath", file.getPath());
// Adding each song to SongList
songsList.add(song);
}
}
return songsList;
}
class FileExtensionFilter implements FilenameFilter
{
public boolean accept(File dir, String name)
{
return (name.endsWith(".mp3") || name.endsWith(".MP3") || name.endsWith(".mp4") || name.endsWith(".MP4"));
}
}