android 1.5,通过编程将歌曲表单/sdcard/songs复制到/sdcard/backup
我正在使用eclipse emulator,我想以编程方式将一些MP3从/sdcard/songs复制到/sdcard/backup,有什么办法吗? 非常感谢任何帮助和代码片段! 谢谢!:) 您可以尝试以下方法:android 1.5,通过编程将歌曲表单/sdcard/songs复制到/sdcard/backup,android,backup,mp3,android-sdcard,Android,Backup,Mp3,Android Sdcard,我正在使用eclipse emulator,我想以编程方式将一些MP3从/sdcard/songs复制到/sdcard/backup,有什么办法吗? 非常感谢任何帮助和代码片段! 谢谢!:) 您可以尝试以下方法: try { File sd = Environment.getExternalStorageDirectory(); if (sd.canWrite()) { String sourcePath= "/path/to/source/file.mp3";
try {
File sd = Environment.getExternalStorageDirectory();
if (sd.canWrite()) {
String sourcePath= "/path/to/source/file.mp3";
String destinationPath= "/path/to/destination/file.mp3";
File source= new File(sd, sourcePath);
File destination= new File(sd, destinationPath);
if (source.exists()) {
FileChannel src = new FileInputStream(source).getChannel();
FileChannel dst = new FileOutputStream(destination).getChannel();
dst.transferFrom(src, 0, src.size());
src.close();
dst.close();
}
} catch (Exception e) {}