I am trying to use the realtime database for the first time. The set value function is not working for me.
I already updated the writing rules in the following way :
{
"rules": {
".read": true,
".write": true
}
}
My code looks like this:
Integer Age = 24;
FirebaseDatabase mDatabase = FirebaseDatabase.getInstance();
DatabaseReference sReference = mDatabase.getReference();
sReference.child("Users").child("George").child("Age").setValue(Age)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Toast.makeText(Dashboard.this, "Data stored", Toast.LENGTH_LONG).show();
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(Dashboard.this, "Error", Toast.LENGTH_LONG).show();
}
});
When I print out the reference it is correct. However neither the OnSucces nor the OnFailure is triggered.
Thank you for your help.