How do I edit a child in firebase?

0

In the case there I make a comment and I retrieve, I wanted to know how to edit this child, the comment carries more information like user uid photo and name ... more I did not put it here.

  FirebaseRecyclerAdapter<Cont, BloviewHolderr> firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<Cont, BloviewHolderr>(

            Cont.class,
            R.layout.coment_row,
            BloviewHolderr.class,
            mQueryCurrentUser

    ) {
        @Override
        protected void populateViewHolder(BloviewHolderr viewHolder, Cont model, int position) {
            final String user_key = getRef(position).getKey();
            //viewHolder.set_nome(model.getName());
            viewHolder.setComentario(model.getComentario());
            viewHolder.setUsername(model.getUsername());
            viewHolder.setData(model.getData());
            viewHolder.setFtperfil(getApplicationContext(), model.getFtperfil());

            viewHolder.mView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    Intent singleBlogIntent = new Intent (Comentarios.this, Perfil.class);
                    singleBlogIntent.putExtra("blog_id", user_key);
                    startActivity(singleBlogIntent);

                }
            });


        }

    };
    mSingleComentBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            final String coment_val = mSingleBlogComent.getText().toString().trim();


                            if (!TextUtils.isEmpty(coment_val)) {



                final String user_id = mAuth.getCurrentUser().getUid();
                final String post_key = getKey();
                final DatabaseReference newComent = mDatabaseComent.push();
                mDatabaseUser.addValueEventListener(new ValueEventListener() {
                    @Override
                    public void onDataChange(DataSnapshot dataSnapshot) {

                        newComent.child("comentario").setValue(coment_val);

                    }


                    @Override
                    public void onCancelled(DatabaseError databaseError) {

                    }
                });

            }

        }
    });
    mComentList.setAdapter(firebaseRecyclerAdapter);

}

public static class BloviewHolderr extends  RecyclerView.ViewHolder{

    View mView;

    public BloviewHolderr(View itemView) {
        super(itemView);

        mView = itemView;
    }
    public void setComentario (String comentario) {
        TextView post_coment = (TextView) mView.findViewById(R.id.messageComent);
        post_coment.setText(comentario);
      }}

My Unanswered Questions: Problem in retrieving data on map (Firebase )

My Unanswered Questions: Trouble recovering with Firebase

    
asked by anonymous 23.02.2017 / 16:37

1 answer

0

After recovering the comment, you use the same path that you retrieved to publish again. The comment will be replaced.

    
23.02.2017 / 16:49