我在我的 RES一些音频文件/原
文件夹。出于某些原因,我想这个文件复制到我的SD卡时,我的应用程序启动。
I've some audio files in my res/raw
folder. For some reasons, i want to copy this files to my SDCard When, my application starts.
我怎么能这样做呢?任何人指导我?
How can i done this? Anyone guide me?
从资源读取,写入SD卡上的文件:
Read from the resource, write to a file on the SD card:
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();
}
上一篇:为什么我的比较方法抛出异常 - 比较法违反了一般的合同!我的、比较法、抛出、异常
下一篇:如何从Facebook SDK在Android应用程序获取电子邮件ID?应用程序、电子邮件、SDK、Facebook