title: ObjectInputStream doesnt work as expected
body: <p>I'm trying to save an object to a file and read it again, here is the code I'm using:</p>
  
  <p>This code to store the object to a file: (called in onDestroy)</p>
  
  <pre><code>    private void serializeModulesManager() {
          try {
              FileOutputStream fos = openFileOutput("modules.txt",
                      Context.MODE_PRIVATE);
              ObjectOutputStream out = new ObjectOutputStream(fos);
              out.writeObject(Module.values());
              out.flush();
              out.close();
              fos.close();
          } catch (FileNotFoundException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>This code to read the object from the file: (called in onCreate())</p>
  
  <pre><code>private void restoreModulesManager() {
          FileInputStream fileIn;
          Module[] arr = null;
          try {
  
              fileIn = openFileInput("modules.txt");
              ObjectInputStream in = new ObjectInputStream(fileIn); 
  
              arr = (Module[]) in.readObject(); // "in" object is empty so I cant read anything from it.. I get an EOFException and get to IOException
  
              for (Module c : arr) {
                  Module.valueOf(c.name()).serilize(c);
              }
  
              in.close();
              fileIn.close();
          } catch (FileNotFoundException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (StreamCorruptedException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (ClassNotFoundException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>The problem is in the restoreModulesManager() function: When I close the application from the task manager, or restart the device, the "ObjectInputStream in" object is empty so I cant read anything from it in the next line..</p>
  
  <p>Any idea why is this happening?</p>
  
  <p>stacktrace:</p>
  
  <pre><code>12-16 20:53:40.395: W/System.err(18512): java.io.EOFException
  12-16 20:53:40.415: W/System.err(18512):    at java.io.DataInputStream.readByte(DataInputStream.java:98)
  12-16 20:53:40.415: W/System.err(18512):    at java.io.ObjectInputStream.nextTC(ObjectInputStream.java:506)
  12-16 20:53:40.425: W/System.err(18512):    at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:778)
  12-16 20:53:40.425: W/System.err(18512):    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:2006)
  12-16 20:53:40.435: W/System.err(18512):    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1963)
  12-16 20:53:40.435: W/System.err(18512):    at com.technion.coolie.CoolieActivity.restoreModulesManager(CoolieActivity.java:489)
  12-16 20:53:40.445: W/System.err(18512):    at com.technion.coolie.CoolieActivity.onCreate(CoolieActivity.java:52)
  12-16 20:53:40.445: W/System.err(18512):    at com.technion.coolie.skeleton.MainActivity.onCreate(MainActivity.java:28)
  12-16 20:53:40.445: W/System.err(18512):    at android.app.Activity.performCreate(Activity.java:5250)
  12-16 20:53:40.445: W/System.err(18512):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
  12-16 20:53:40.455: W/System.err(18512):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2210)
  12-16 20:53:40.455: W/System.err(18512):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2296)
  12-16 20:53:40.455: W/System.err(18512):    at android.app.ActivityThread.access$700(ActivityThread.java:151)
  12-16 20:53:40.455: W/System.err(18512):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
  12-16 20:53:40.455: W/System.err(18512):    at android.os.Handler.dispatchMessage(Handler.java:99)
  12-16 20:53:40.455: W/System.err(18512):    at android.os.Looper.loop(Looper.java:137)
  12-16 20:53:40.455: W/System.err(18512):    at android.app.ActivityThread.main(ActivityThread.java:5293)
  12-16 20:53:40.465: W/System.err(18512):    at java.lang.reflect.Method.invokeNative(Native Method)
  12-16 20:53:40.465: W/System.err(18512):    at java.lang.reflect.Method.invoke(Method.java:511)
  12-16 20:53:40.465: W/System.err(18512):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
  12-16 20:53:40.465: W/System.err(18512):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
  12-16 20:53:40.465: W/System.err(18512):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>