I have an index.html file and some images displayed on this page stored in res/raw folder.
I need to open this file in android browser. So, I copy this file into sdcard.
But if i use R.raw.index the index file only copied other files are not copied. Since other html and images are not copied to sdcard: I don't see the images when I open index.html in browser.
Here is my current code to copy raw resource:
private File copyFile(int resourceId, String filename) {
InputStream in = null;
OutputStream out = null;
File outFile = null;
try {
in = mContext.getResources().openRawResource(resourceId);
outFile = new File(mContext.getExternalFilesDir(null), filename);
Log.d("TestHTML", "output file" + outFile.getAbsolutePath());
out = new FileOutputStream(outFile);
byte[] buffer = new byte[1024];
int read;
while((read = in.read(buffer)) != -1){
out.write(buffer, 0, read);
}
} catch(IOException e) {
Log.e("TestHTML", "Failed to copy file", e);
} finally {
try {
in.close();
out.flush();
out.close();
in = null;
out = null;
} catch (Exception e){}
}
return outFile;
}
And here is the layout of the res/raw folder
Can you give me a hint on how to copy the whole content of the res/raw directory to the internal storage ?