I’ve launched an app that saves its state with serialized object myfirstpath.UserState.
Now for I want to change the path of this object to mycleanpath.UserState (same object, only the path changes). This will work for new users installing the app for the first time but for users updating the app, they will lose their state.
Is there a way to load the serialized obect myfirstpath.UserState into mycleanpath.UserState ? (without keeping myfirstpath.UserState in my source code of course).
I wrote a little piece of code to search/replace the old path/new path in the file containing the serialized data. I convert the file before I load it, this way I can move the serialized class to the new path without keeping copy of this class at the old path. This is how you you use it :
And this is the code of SerializeTools.java. I’ve learned the java Serialize format in this great blog post http://www.javaworld.com/community/node/2915 .