I'm trying to save a random hello world file onto the internal storage of my android. When I run my app, it simply stops.
Code:
public void saveDataOnDevice(String toWrite, String filename) {
Context ctx = null;
try {
FileOutputStream fos = ctx.openFileOutput(filename, Context.MODE_PRIVATE);
fos.write(toWrite.getBytes());
fos.close();
}
catch (IOException ioe) {
ioe.printStackTrace();
}
}
Another question is, what Context
means. I read a lot about this here, but I still don't get it.