我正在学习如何使用SQLite Databses,我有一个如何使用简单数据的要点,例如我知道我可以将数据类型TEXT的名称和电子邮件存储到表中 . 现在,我想将同样的东西应用于更复杂的对象,存储我的Alarm对象 . 我的警报看起来像
public class Alarm {
public int st;
public String name;
public String time;
public String date;
public long mili; ///calender time
public Intent intent;
public PendingIntent pendingIntent;
public AlarmManager manager;
public Alarm(String name, String time, String date, int st, long mili, Intent intent, PendingIntent pendingIntent, AlarmManager manager){
this.name = name;
this.time = time;
this.date = date;
this.st = st;
this.mili = mili;
this.intent = intent;
this.pendingIntent = pendingIntent;
this.manager = manager;
}
}
我知道我可以使用诸如INTEGER和TEXT之类的数据类型来存储我的字符串和整数,但是有没有办法存储诸如意图,待定意图和管理器之类的东西 . 我有一个这些对象的列表,我在不同的类中使用,所以我需要能够访问每个警报对象意图,待定意图和管理器,以便我可以重置和取消警报,因此我发现它很容易存储对象中的数据 . 但是我不确定这实际上可以保存在SQL表中 . 有人会与我分享一些提示吗?
1 回答
是否有任何特定的文件,我应该在序列化时实际保存我的对象? nope,你编码,然后在字节流中将它保存在db中 . 是否有特定文件,如SharedPrefrences或我应该使用的东西,或者我可以使用类似alarmsList.txt的东西?看看这个https://android.jlelse.eu/parcelable-vs-serializable-6a2556d51538也许你会得到更多的信息是否有一个特定的文件夹(也许是原始的?)没必要谢谢!