Reputation: 1
I was working on a project, While working on a real-time database the references are correctly configured but retuning null.
DatabaseReference reference = database.getReference(map.get(SessionManager.KEY_CARID)+"/Alert/status");
//DatabaseReference reference = database.getReference(map.get(SessionManager.KEY_CARID)).child("Alert").child("status");
reference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
if (snapshot.getValue().toString().equalsIgnoreCase("1")) {
In this if statement the function tostring() is not working as its giving null pointer exception. The database structure is as followed.
Upvotes: 0
Views: 62
Reputation: 80924
Try the following:
DatabaseReference reference = database.getReference("User").child(map.get(SessionManager.KEY_CARID)).child("Alert").child("status");
You need to reference the node User
Upvotes: 1