title: Android NotSerializableException raises for an object
body: <p>In my <strong>android</strong> application I use a <strong>file to store license data</strong>. And I uses <strong>Serialize objects</strong>. I create a <strong>Device</strong> object and read the file details in to the object. <strong>Device class implements Serializable</strong>.</p>
  
  <pre><code>public class MyDevice implements Serializable {}
  </code></pre>
  
  <p>But at the start of application it <strong>deserialize</strong> and store in a MyDevice  object. My <strong>deserializeObject</strong> method is as below.</p>
  
  <pre><code>public MyDevice deserializeObject() {
  
      File SerialFile = new File(GeoTrackerPaths.FILE_PATH);
      MyDevice AndDeviceIn = new MyDevice();
  
      if (SerialFile.exists()) {
          try {
              FileInputStream fileIn = new FileInputStream(GeoTrackerPaths.FILE_PATH);
              ObjectInputStream objInput = new ObjectInputStream(fileIn);
              AndDeviceIn = (MyDevice) objInput.readObject();
              objInput.close();
              fileIn.close();
  
          } catch (Exception e) {
  
              Log.i("TAG", "Exception during deserialization:" + e.getMessage());
              e.printStackTrace();
              System.exit(0);
          }
      }
  
      return AndDeviceIn;
  }
  </code></pre>
  
  <p>My serialization code</p>
  
  <pre><code>public void serializeObject(Context context, String phoneModel,
          String androidVersion, String executiveCode, String Key,
          String modelID, String tempKey, int noLogin, String expireDate, String Status) {
  
      try {
          MyDevice AndDeviceOut = new MyDevice(context, phoneModel,
                  androidVersion, new Date(), executiveCode, Key, modelID,
                  tempKey, noLogin, expireDate, Status);
  
          FileOutputStream fileOut = new FileOutputStream(
                  GeoTrackerPaths.FILE_PATH);
          ObjectOutputStream objOutput = new ObjectOutputStream(fileOut);
          objOutput.writeObject(AndDeviceOut);
          objOutput.flush();
          objOutput.close();
          fileOut.close();
  
      } catch (Exception e) {
          Log.i("TAG", "Exception during serialization:" + e.getMessage());
          e.printStackTrace();
          System.exit(0);
      }
  }
  </code></pre>
  
  <p>And I'm calling it as below.</p>
  
  <pre><code>DeviceActivator activate=new DeviceActivator();
  activate.serializeObject(Activation.this, phoneModel, androidVersion, txtExe, exeKey, modeilID, tempKey, noLogin, expireDate, Activation_Status);
  </code></pre>
  
  <p>when I'm running the app following exceptions are raised. </p>
  
  <pre><code>java.io.WriteAbortedException: Read an exception; 
  java.io.NotSerializableException: com.geotracker.entity.MyDevice
  </code></pre>
  
  <p>How can I fix this?</p>