title: Serialize - failing after package renaming
body: <p>Appended are my little utility functions for serialising objects. I just encountered following problem:</p>
  
  <p>I renamed a package and suddenly I get a <code>java.lang.ClassCastException</code> when opening my app and trying to read serialised data...</p>
  
  <p><em>Can I somehow solve that? I would like my serialisations to be working after a renaming, can I do something to implement this? Via some versioning for example?</em></p>
  
  <p>Here are my two simple functions I use currently:</p>
  
  <pre><code>public static String serialize(Object object)
  {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      try
      {
          ObjectOutputStream oos = new ObjectOutputStream(baos);
          oos.writeObject(object);
          oos.flush();
          oos.close();
      } catch (IOException e)
      {
          L.e(StringUtil.class, e);
      }
      return Base64.encodeToString(baos.toByteArray(), 0);
  }
  
  public static &lt;T&gt; T deserialize(String serializedObject, Class&lt;T&gt; clazz)
  {
      if (serializedObject == null)
          return (T)null;
  
      byte [] data = Base64.decode(serializedObject, 0);
      Object o = null;
      try
      {
          ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(data));
          o = ois.readObject();
          ois.close();
      }
      catch (IOException e)
      {
          L.e(StringUtil.class, e);
      }
      catch (ClassNotFoundException e) {
          L.e(StringUtil.class, e);
      }
  
      return (T)o;
  }
  </code></pre>