首先,我认为这是我的错,我只是在项目后期才开始使用Firebase。
无论如何,我想做的是将Pub对象存储到数据库中。它包含各种信息,例如开放时间,评级,设施等。
问题不在存储中,而是每当我试图从数据库中获取酒吧列表时,我都会遇到这个问题
这是错误。
com.google.firebase.database.DatabaseException: Could not find enum value of com.example.matasolutions.pintindex.Day for value "Monday"
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.deserializeToEnum(com.google.firebase:firebase-database@@16.1.0:302)
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.deserializeToClass(com.google.firebase:firebase-database@@16.1.0:212)
at com.google.firebase.database.core.utilities.encoding.CustomClassMapper.deserializeToType(com.google.firebase:firebase-database@@16.1.0:178)
这是枚举类。
public enum Day {
MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY,SUNDAY
};
这就是具有枚举的构造函数的外观
public SingleOpeningHours(Day dayOfTheWeek,String openingTime, String closingTime){
this.dayOfTheWeek = dayOfTheWeek;
this.openingTime = openingTime;
this.closingTime = closingTime;
}
最后,这就是它如何被添加到列表中,然后添加到数据库中。
ArrayList<SingleOpeningHours> singleOpeningHours = new ArrayList<SingleOpeningHours>();
singleOpeningHours.add(new SingleOpeningHours(Day.MONDAY, "09:00", "00:00"));
singleOpeningHours.add(new SingleOpeningHours(Day.TUESDAY, "09:00", "01:00"));
singleOpeningHours.add(new SingleOpeningHours(Day.WEDNESDAY, "09:00", "01:00"));
singleOpeningHours.add(new SingleOpeningHours(Day.THURSDAY, "09:00","01:00"));
singleOpeningHours.add(new SingleOpeningHours(Day.FRIDAY, "09:00", "01:00"));
singleOpeningHours.add(new SingleOpeningHours(Day.SATURDAY, "09:00", "01:00"));
singleOpeningHours.add(new SingleOpeningHours(Day.SUNDAY, "09:00", "01:00"));
编辑:我有7个枚举类,它们与正在存储的对象相关联。解决此问题的最佳方法是什么?提前感谢各位
jeck猫
相关分类