【发布时间】:2011-07-19 10:47:30
【问题描述】:
我想将 xml 文件从 res/raw 文件夹复制到 sd 卡。这个问题实际上是特定于 ODK 收集的。但任何帮助将不胜感激。我在网上看过Android: How to create a directory on the SD Card and copy files from /res/raw to it? 和其他类似的帖子,但我仍然无法复制。也许是因为我正在开发 ODK Collect。 这是我复制文件的代码:
try {
InputStream in = getResources().openRawResource(R.raw.problem2);
OutputStream out = new FileOutputStream(Collect.FORMS_PATH+"/problem2");
// 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) { }
提前致谢。
【问题讨论】:
-
是的,它是用于 xforms 等的软件...
-
Collect.FORMS_PATH 的值是多少?
-
Environment.getExternalStorageDirectory() + "/odk/forms"
标签: android