I have a class called FileGeneration that extends Activity.
In FileGeneration I have a method called
protected OutputStream openAndWriteFile() {
int cxt = Context.MODE_PRIVATE;
if (!clearFile && (new File(this.fileName)).exists()) {
cxt = Context.MODE_APPEND;
}
try {
this.os = openFileOutput(this.fileName, cxt);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return this.os;
}
And I get this output in Logcat
06-08 15:31:43.733: ERROR/AndroidRuntime(2850): java.lang.NullPointerException
06-08 15:31:43.733: ERROR/AndroidRuntime(2850): at android.content.ContextWrapper.openFileOutput(ContextWrapper.java:158)
06-08 15:31:43.733: ERROR/AndroidRuntime(2850): at android.content.ContextWrapper.openFileOutput(ContextWrapper.java:158)
06-08 15:31:43.733: ERROR/AndroidRuntime(2850): at dataconnection.FileGeneration.openAndWriteFile(FileGeneration.java:278)
Line 278 in class
this.os = openFileOutput(this.fileName, cxt);
But when I just print the method with parameters in Logcat, it says
openFileOutput(Preferences.xml, 1);
The file does not exist, but openFileOutput says that it will create it if it does not exist
What could be wrong?
source
share