I have implemented Serializable objects in my android app to keep backward compatibility.
Sadly i created my classes like this:
Class Foo implements Serializable {
private static long serialVersionUID = 928374172L;
[...]
}
As i painfully figured out, Java doesn't recognize this value as the serialVersionUID because the "final" statement is missing.
The problem is i can't create the private static final long serialVersionUID
because there is already an object named like this... :/
Is there any chance to save this class or do i have to create a Foo2
class and copy all saved data into it? Maybe any better way? Because i have to modify this class without loosing all saved data.
Your current serialVersionUID
is static
, so it does not participate in the (de)serialization of the objects. So it is safe to add final
to it.
If your current value is not the default one already, change it, as described here and here.