title: IO Exception in FileInputStream.read. Android
body: <p>I'm writting an Android's app. Two activities, one has TextEdit to type 'hello message', and button to save message in Internal Storage. Second is main activity. Hello mesage should appear after app's start. </p>
  
  <p>Second activity:</p>
  
  <pre><code>    String s = ((EditText) findViewById(R.id.message_act_editText_hello)).getText().toString();
      FileOutputStream fos = openFileOutput(Lab2AndroidActivity.FILENAME, Context.MODE_PRIVATE);
      fos.write(s.getBytes());
      fos.close();
  </code></pre>
  
  <p>first (main) activity:</p>
  
  <pre><code>    static String FILENAME = "message_file.zip";
      FileOutputStream fos;
      try {
          //piece of code to guarantee that file exists
          fos = openFileOutput(Lab2AndroidActivity.FILENAME, Context.MODE_APPEND);
          fos.close();
      } catch (FileNotFoundException e1) {
          e1.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
  
  
      try {
          fis = openFileInput(FILENAME);
          messageString = new StringBuffer("");
          while ((length = fis.read(buffer)) != -1) {
              String temp = new String(buffer, 0,length);
              messageString.append(temp);
              fis.close();
          }
      } catch (FileNotFoundException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
  
      Toast t = Toast.makeText(this, messageString, 3000);
      t.show();
  </code></pre>
  
  <p>I'm getting IO Exception in logcat at line:</p>
  
  <pre><code>  while ((length = fis.read(buffer)) != -1)
  </code></pre>
  
  <p>but app seems to work correctly (defined message appears after app's start). I tried to find explanation, I found several topics, but all was according to large files, or files in assets, or compressed files.
   I tried to name my file like </p>
  
  <pre><code>static String FILENAME = "message_file.zip",
  static String FILENAME = "message_file.txt", 
  </code></pre>
  
  <p>to try different extensions, but always i'm getting the same IO Exception.</p>
  
  <p>Thanks for suggestions. </p>