大家好,我在资产文件夹中有一个音频文件,我需要将相同的文件保存到 sdcard 上。
如何实现这一点。
下面是我用来保存文件的代码
String filename = "filename.txt";
File file = new File(Environment.getExternalStorageDirectory(), filename);
FileOutputStream fos;
byte[] data = new String("data to write to file").getBytes();
try {
fos = new FileOutputStream(file);
fos.write(data);
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
// handle exception
} catch (IOException e) {
// handle exception
}
请帮忙