I am a beginner and I am making a simple android game in which a user sign in into the app and play the game. After the game finishes I want to add the current score of the user with previous score and then store this total score in Firebase and then again retrieve the score next time when the user plays game.
I am not getting on how should I save the Total score for every different user who sign in.
this is my firebase json tree https://drive.google.com/file/d/1T7-x3TP1TaA8_ntwfoRNdb2oMGV_swl6/view?usp=sharing
private void updateScore() {
TotalScore = new Firebase("https://bscitquiz.firebaseio.com/Users/" + username +"/highScore");
TotalScore.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Integer totalscore = dataSnapshot.getValue(Integer.class);
totalscore = totalscore + mScore;
dataSnapshot.getRef().setValue(totalscore);
HighScore.setText("" +totalscore);
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
}