Firebase Veri Okuma

Firebase Veri Okuma

private DatabaseReference mDatabaseRead;
mDatabaseRead = FirebaseDatabase.getInstance().getReference().child("users").child("1");
   private void getValue() {

        ValueEventListener getHighScore = new ValueEventListener() {
            @Override
            public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                User getUser = new User();
                getUser=dataSnapshot.getValue(User.class);
                highScore = getUser.getHighScore();
                txtHighScore.setText("High Score: " + Integer.toString(highScore));
            }

            @Override
            public void onCancelled(@NonNull DatabaseError databaseError) {

            }
        };
        mDatabaseRead.addValueEventListener(getHighScore);
    }

Leave a Reply