I fetched a value from database and stored in a variable. I exactly got the expected value. But when I try to set those value into a textview it shows null or 0. Why this happening? How to solve this?
I used,
claimedNos = dataSnapshot.child("Claimed").getValue(int.class);
this code for getting data from database.
valueClaimed.setText(String.valueOf(claimedNos));
this for setting value to textview.
code is here,
public int claimedNos;
uDatabase.child(userId).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
claimedNos = dataSnapshot.child("Claimed").getValue(Integer.class);
Log.d("TAG","claimed nos in account :"+claimedNos);
}