我想序列化android.net.Uri类型的对象的状态.
下面是我的带有writeObject和readObject方法的模型类
public class ReminderObject implements Serializable {
private boolean isReminderOn;
private int fromHours, toHours;
private int interval;
private ArrayList<CharSequence> daysToRepeat;
private Uri toneToPlay;
private AdvanceSettingsObject adv;
public ReminderObject(boolean isReminderOn, int fromHours, int toHours,
int interval, ArrayList<CharSequence> daysToRepeat, Uri toneToPlay,
AdvanceSettingsObject adv) {
super();
this.isReminderOn = isReminderOn;
this.fromHours = fromHours;
this.toHours = toHours;
this.interval = interval;
this.daysToRepeat = daysToRepeat;
this.toneToPlay = toneToPlay;
this.adv = adv;
}
/*
getters and setters
*/
public void writeObject(ObjectOutputStream op){
try {
op.defaultWriteObject();
op.writeChars(toneToPlay.toString());
} …Run Code Online (Sandbox Code Playgroud)