I want to copy a xml file from res/raw folder to the sd card. This question is actually specific to the ODK Collect. But any help would be appreciated. I have looked at Android: How to create a directory on the SD Card and copy files from /res/raw to it? and other similar posts on the web but I was still unable to copy. Maybe, its because I am working on ODK Collect. This is my code for copying the file:
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) { }
Thanks in advance.