I want to get last "current unit" of unique customer from Firebase database.I'm new to here. Please help me. Here is my database snapshot:
I tried to with this code. But not value pass to textview. I don't know where is the error.Not Showing any errors.
databaseBills = FirebaseDatabase.getInstance().getReference("bills");
Query lastQuery = databaseBills.child("bills").orderByKey().limitToLast(1);
lastQuery.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
String value = dataSnapshot.child("current_units").getValue(String.class);
textView17.setText(value);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});