title: Android ObjectInputStream readObject throws IllegalAccessException
body: <p>I am trying to write a Serialized Object in my onPause method into a file so that I can read it again from the file when I start the app another time and need the previous data. </p>
  
  <p>This is where i save the Object</p>
  
  <pre><code>try {
      FileOutputStream fout = openFileOutput(logFileName, MODE_PRIVATE);
      ObjectOutputStream fw = new ObjectOutputStream(fout);
      fw.writeObject(obj);
      Log.d("obj", "added");
      fw.close();
  } catch (Exception e) {
      Log.d("obj", "not added");
      e.printStackTrace();
  }
  return;
  </code></pre>
  
  <p>I can see the "added" message and this means that the Object has been saved in the file.</p>
  
  <p>Here is where i try to read the saved object:</p>
  
  <pre><code>try {
      FileInputStream fin = openFileInput(logFileName);
      ObjectInputStream fread = new ObjectInputStream(fin);
      Object res = fread.readObject();
      Log.d("obj", "readed successfully");
  } catch (Exception e) {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>And I get this :</p>
  
  <pre><code>java.io.InvalidClassException: android.view.View; IllegalAccessException
  </code></pre>
  
  <p>on the line calling "fread.readObject()". I would thank you if you could please tell me why is it throwing the following Exception.
  Thanks in Advance.</p>