将我的应用程序资源中的文件复制到SD卡中的新文件

我试图从可能应用程序的资源中复制图像文件到SD卡中的新文件。 但我在LogCat中收到一个错误:

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)

这是我的代码:

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/93079.html

上一篇: copy a file from resources of my app to a new file in sdcard

下一篇: Moving files from sdCard to flash memory in android?