Note that there are some explanatory texts on larger screens.

plurals
  1. PONullPointer exception in ContextWrapper
    primarykey
    data
    text
    <p>I have a class called FileGeneration that extends Activity<br /> In FileGeneration I have a method called</p> <pre><code>protected OutputStream openAndWriteFile() { // Set the Context-mode int cxt = Context.MODE_PRIVATE; // Check if we are not going to clear the file and the file exists if (!clearFile &amp;&amp; (new File(this.fileName)).exists()) { // Append to the file cxt = Context.MODE_APPEND; } // Try to open the file to write to try { // Open the File using the Context this.os = openFileOutput(this.fileName, cxt); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } // Return the OutputStream return this.os; } </code></pre> <p>And I get this output in Logcat</p> <pre><code>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) </code></pre> <p>Line 278 in the class is</p> <pre><code>this.os = openFileOutput(this.fileName, cxt); </code></pre> <p>But when I just print the method with the paramters out in Logcat it says</p> <pre><code>openFileOutput(Preferences.xml, 1); </code></pre> <p>The file does not exist, but openFileOutput says it will create it, if it does not exist</p> <p>What can be wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload