I getting android.widget.ImageView; IllegalAccessException when trying to deserialize my previously serialized object
File presetFile = new File("pathToFile");
FileInputStream fis = new FileInputStream(presetFile);
ObjectInputStream ois = new ObjectInputStream(fis);
Preset preset = (Preset) ois.readObject();
I’m guessing that there is some restriction about ImageView, explanation below:
public class Preset implements Serializable {
private Date dateOfCreation;
private int bpm;
private SoundSwitch[][] switches;
And finally SoundSwitch class header
public class SoundSwitch extends ImageView implements Serializable{
}
Is that because ImageView that I inherit from doesn’t implement Serializable? Do I have to give up on deserializing such object?
It is because the
ImageViewyou are inheriting from is non-Serializable and doesn’t have a public no-args constructor. Evidently it has a protected or package-access or private one.