从原材料到目录拷贝SD卡文件 [英] Copy file from raw dir to SDcard
本文介绍了从原材料到目录拷贝SD卡文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从我的应用程序复制一个MP3文件的 原材料 的文件夹中的 的/ mnt / SD卡 的,但我不知道这份工作。
I want to copy a mp3 file from my app raw folder to /mnt/SDcard but i have no idea for this job.
这是不可能的?
如果您有任何答案告诉我有关权限,那些codeS需求;
If you have any answer tell me about permissions that those codes needs;
感谢名单。
推荐答案
下面是你可以用做什么:
Here is what you can use to do that :
InputStream in = getResources().openRawResource(R.raw.myresource);
FileOutputStream out = new FileOutputStream(somePathOnSdCard);
byte[] buff = new byte[1024];
int read = 0;
try {
while ((read = in.read(buff)) > 0) {
out.write(buff, 0, read);
}
} finally {
in.close();
out.close();
}
这篇关于从原材料到目录拷贝SD卡文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文