it don't just do with this data , error is same with
when i save data from other device into databse (firebase) app crashes where data is retrieved and set into recycle view in other device
onDataChange is realtime when data is changed it is automatically called
Notification Class
public class Notifications {
private String Name;
private String Email;
private String Message;
private String Time;
private String Date;
public Notifications() {
}
public Notifications(String Name, String Email, String Message, String Time, String Date) {
this.Name = Name;
this.Email = Email;
this.Message = Message;
this.Time = Time;
this.Date = Date;
}
public String getName() {
return Name;
}
public String getEmail() {
return Email;
}
public String getMessage() {
return Message;
}
public String getTime() {
return Time;
}
public String getDate() {
return Date;
}
}
DatabaseReference userref = FirebaseDatabase.getInstance().getReference().child("Notification");
userref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
if (dataSnapshot.exists()) {
notificationList.clear();
for (DataSnapshot userSnapshot : dataSnapshot.getChildren()) {
Notifications notifications = userSnapshot.getValue(Notifications.class);
notificationList.add(notifications);
}
Collections.reverse(notificationList);
mAdapter = new Adapter_Notification(notificationList);
mRecyclerView.addItemDecoration(new DividerItemDecoration(getContext(), LinearLayoutManager.VERTICAL));
mRecyclerView.setAdapter(mAdapter);
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
this error is shown
com.google.firebase.database.DatabaseException: Can't convert object of type java.lang.Boolean to type com.example.simpleapplocker.Notifications
at the line
notificationList.add(notifications);
after start is retrieves that data and shows in recycle view it mean data exists or maybe notification is created but other data is not uploaded and this function is called maybe??