patient=mFirebaseAuth.getCurrentUser();
databaseReference=FirebaseDatabase.getInstance().getReference("Patients");
Query query= databaseReference.orderByChild(patient.getUid());
query.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for (DataSnapshot ds : dataSnapshot.getChildren()){
deviceId= String.valueOf(ds.child("devID").getValue());
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
databaseReferences= FirebaseDatabase.getInstance().getReference(deviceId).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for (DataSnapshot ds : dataSnapshot.getChildren()){
mbt= String.valueOf(ds.child("BT").getValue());
Log.d("myTag", "This is my message"+mbt);
Toast.makeText(getApplicationContext(),"Hi"+mbt,Toast.LENGTH_SHORT).show();
bt.setText(mbt);
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
Log
D/myTag: This is my message98.9
D/myTag: This is my messagenull
Here, in this, at first in Log and as well as in toast, I'm getting the actual value for some moments and after a while its changing to null. and my console and code screenshot is,
My firebase database structure is...
{
"123456" : {
"BT" : 98.9,
"DBP" : 80,
"HR" : 90,
"SBP" : 125.5
},
"Patients" : {
"I6nb3CB52ARmWtfpA5ZRpLjiNbx1" : {
"age" : "22",
"devID" : "123456",
"eillness" : "Corona",
"email" : "asdf@gmail.com",
"fname" : "asdf",
"lname" : "jkl"
}
}
}
Here, in this, at first in Log and as well as in toast, and texview also I'm getting the actual value for some moments and after a while its changing to null.