title: Error: FileOutputStream may not be initialized
body: <p>I'm trying to run this piece of code inside my onCreate method as an initial test into writing private data for my app to use. This code is straight out of the Android SDK development guide located <a href="http://developer.android.com/guide/topics/data/data-storage.html#filesInternal" rel="nofollow noreferrer">here</a></p>
  
  <pre><code>String FILENAME = "hello_file";
  String string = "hello world!";
  
  FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
  fos.write(string.getBytes());
  fos.close();
  </code></pre>
  
  <p>However, this code give me errors for the 3 lines of code at the bottom. The error is an unhandled exception. The suggested quick fix is do to the following:</p>
  
  <pre><code>    String FILENAME = "hello_file";
      String string = "hello world!";
  
      FileOutputStream fos;
      try {
          fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
      } catch (FileNotFoundException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      try {
          fos.write(string.getBytes());
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      try {
          fos.close();
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  </code></pre>
  
  <p>But after doing that I get an error for the bottom two lines which states that fos may not be initialized. How can I fix this code? </p>