Does anyone know how to write to a text file in Android using a resource like:
R.raw.my_text_file
I'm just looking for something clean and simple. I've Googled around but the examples I found didn't work. I tried to code using the Android docs but couldn't wrap my head around it...
Thanks
EDIT:
I've used the Android docs to create this code. The logs print out "1" and "9" and the code skips everything in between and does nothing:
try {
String filename = "res/raw/my_text_file.txt";
String string;
Log.v(TAG, "1");
FileOutputStream fos = openFileOutput(filename, Context.MODE_PRIVATE);
Log.v(TAG, "2");
for (int i = 0; i < list.size(); i++) {
Log.v(TAG, "3");
try {
Log.v(TAG, "4");
string = i + " - " + list.get(i);
fos.write(string.getBytes());
} catch (Exception e) {
Log.v(TAG, "5");
}
Log.v(TAG, "6");
}
Log.v(TAG, "7");
fos.close();
Log.v(TAG, "8");
} catch (Exception e) {
}
Log.v(TAG, "9");