小编sha*_*l46的帖子

序列化android.net.Uri对象

我想序列化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)

serialization android

5
推荐指数
2
解决办法
5511
查看次数

标签 统计

android ×1

serialization ×1