copy a file from resources of my app to a new file in sdcard
I'm trying to copy a image file from resources of may app to a new file in sdcard. But i receive in LogCat an error:
12-10 01:34:38.292: W/System.err(29307): java.io.FileNotFoundException: /es.epinanab.eic:raw/termo_k: open failed: ENOENT (No such file or directory)
This is my code:
File src = new File(getResources().getResourceName(R.raw.termo_k));
File dest = new File(Environment.getExternalStorageDirectory() + "/.EIC/termo_k.jpg");
try {
InputStream in = null;
in = new FileInputStream(src);
OutputStream out = null;
out = new FileOutputStream(dest);
// Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
链接地址: http://www.djcxy.com/p/93080.html
上一篇: 如何从SD卡中绘制位图到自定义的抽取方法