Add +1 every time a child is called Fire Base

0

Hello, here I am again with the fire base saga: p,

So how can I add +1 to child Users when someone enters an activity, in the case of a user profile, I want to do the same in the profile of the community here, Thanks in advance.

I think this is the starting point

        mDatabase = FirebaseDatabase.getInstance().getReference().child("Users");
        mPost_key = getIntent().getExtras().getString("uidusuario");

        mDatabase.child(mPost_key).addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
        mDatabase.child(mPost_key).child("visitasperfil").setValue();
    
asked by anonymous 07.03.2017 / 14:55

1 answer

1
      mDatabaseVisitas.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            //Log.e(String.valueOf(dataSnapshot.child(post_key)),dataSnapshot.getChildrenCount() + "");

            for (DataSnapshot snap: dataSnapshot.getChildren()) {
                //Log.e(String.valueOf(snap.child(currentUserId).toString()),snap.getChildrenCount() + "");
                mVisitas.setText(dataSnapshot.child(currentUserId).getChildrenCount() + "");
            }}
        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });
    final String user_id = mAuth.getCurrentUser().getUid();
    mDatabaseVisitas.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            mDatabaseVisitas.child(currentUserId).child(mAuth.getCurrentUser().getUid()).setValue("true");

        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });
    
15.04.2017 / 20:36