Thanks for the previous help, I managed to write to the firebase database, the problem now is that **I can't take the specific node to edit.**

When opening an element from a `recyclerview`  and obtaining the data and modifying the `interno`  value and pressing `update button` , **the database checks it but saves it outside the uid of the selected cow**. You can see it better in the image.

[![enter image description here](https://i.stack.imgur.com/eN3je.png)](https://i.stack.imgur.com/eN3je.png)

This is the code where im trying to do the `update`. I've been testing and may have missing or leftover code, sorry. I do it only with `interno` as a test to later add the rest of the keys

```
  private void Update() {
        DatabaseReference ref = FirebaseDatabase.getInstance().getReference().child("Vacas");
        String key = ref.child("Vacas").push().getKey();
        Cow cow = new Cow();
        Map<String, Object> updates = new HashMap<String, Object>();
        updates.put("interno", tvinterno.getText().toString());
        ref.updateChildren(updates);
    }

```

I am not taking the reference correctly, I hope you can help me solve this problem, thank you

**EDIT**

I am using the `database` in a `recyclerview`, you can see in the image, when I click on a `cow`, a **new activity opens with all the information in the database, this is where I am interested in editing the values** ​​( Attached image).

**I want to edit the values ​​based on the selected cow from the app**, this is where I don't know if the solution you proposed to Mr. HaroldSer and Mr. Arup will work

**EDIT 2**

This is how I set the values ​​in the `Edit activity`

in my `adapter` in the `onBindViewHolder`, I send them to the `Edit activity` through an `intent`

```
@Override
    public void onBindViewHolder(@NonNull final cowviewHolder holder, int position) {
        final Cow vacaslist = vacas.get(position);
        holder.textViewinterno.setText(vacaslist.interno);
        holder.textViewsiniiga.setText(vacaslist.siniiga);
        String url= vacaslist.getUrl();

        if (url == null|| url.isEmpty()){
            holder.imageviewrec.setImageResource(R.drawable.ic_imageinf);
        } else {
            Picasso.get().load(vacaslist.getUrl()).error(R.drawable.ic_imageinf).into(holder.imageviewrec);
        }

        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(v.getContext(), Cowdetail.class);
                intent.putExtra("keyint", vacaslist.getInterno());
                intent.putExtra("keysin", vacaslist.getSiniiga());
                intent.putExtra("madre", vacaslist.getMadre());
                intent.putExtra("padre", vacaslist.getPadre());
                intent.putExtra("nacimiento", vacaslist.getNacimiento());
                intent.putExtra("toro", vacaslist.getToro());
                intent.putExtra("estatus", vacaslist.getEstatus());
                intent.putExtra("inseminacion", vacaslist.getInseminacion());
                intent.putExtra("notas", vacaslist.getNotas());
                intent.putExtra("img", url);
                v.getContext().startActivity(intent);
            }
        });
    }

```

in this way I set them in Edit activity (Cowdetail)

```
public class Cowdetail extends AppCompatActivity {

    EditText tvinterno, tvsiniiga, tvpadre, tvmadre, tvnacimiento, tvinseminacion, tvtoro, tvestatus, tvnotas;
    AppCompatImageView tvimage;
    Button tvbutton;
    String cow_key;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.detailcow);

        tvinterno = (EditText) findViewById(R.id.tvinterno);
        tvsiniiga = (EditText) findViewById(R.id.tvsiniiga);
        tvpadre = (EditText) findViewById(R.id.tvpadre);
        tvmadre = (EditText) findViewById(R.id.tvmadre);
        tvnacimiento = (EditText) findViewById(R.id.tvnacimiento);
        tvinseminacion = (EditText) findViewById(R.id.tvinsemincion);
        tvtoro = (EditText) findViewById(R.id.tvtoro);
        tvestatus = (EditText) findViewById(R.id.tvestatus);
        tvnotas = (EditText) findViewById(R.id.tvnotas);
        tvimage = (AppCompatImageView) findViewById(R.id.tvimage);
        tvbutton = findViewById(R.id.actualizar);

        String vpadre = "";
        String vmadre = "";
        String vinterno = "";
        String vsiniiga = "";
        String vnacimiento = "";
        String vinseminacion = "";
        String vtoro = "";
        String vestatus = "";
        String vnotas = "";
        String vurl;

        Bundle extras = getIntent().getExtras();
        if (extras !=null);
        vinterno = extras.getString("keyint");
        vsiniiga = extras.getString("keysin");
        vmadre = extras.getString("madre");
        vpadre = extras.getString("padre");
        vnacimiento = extras.getString("nacimiento");
        vinseminacion = extras.getString("inseminacion");
        vtoro = extras.getString("toro");
        vestatus = extras.getString("estatus");
        vnotas = extras.getString("notas");
        String image = extras.getString("img");
        if (image == null|| image.isEmpty()){
            tvimage.setImageResource(R.drawable.ic_imageinf);
        } else {
            Picasso.get().load(image).fit().centerCrop().into(tvimage);
        }

        tvpadre.setText(vpadre);
        tvinterno.setText(vinterno);
        tvsiniiga.setText(vsiniiga);
        tvmadre.setText(vmadre);
        tvnacimiento.setText(vnacimiento);
        tvinseminacion.setText(vinseminacion);
        tvtoro.setText(vtoro);
        tvestatus.setText(vestatus);
        tvnotas.setText(vnotas);

        tvbutton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Update();
            }
        });

    }

    private void Update() {
        DatabaseReference ref = FirebaseDatabase.getInstance().getReference().child("Vacas");
        String key = ref.child("interno").getKey();
        Cow cow = new Cow();
        Map<String, Object> updates = new HashMap<String, Object>();
        updates.put("interno", tvinterno.getText().toString());
        ref.child(key).updateChildren(updates)
      }

}

```

**EDIT 3**

this is how i add the `node_id` to `onDataChange`

```
  mReferenceCow.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(@NonNull DataSnapshot snapshot) {
                vacas.clear();
                for (DataSnapshot snapshot1 :
                        snapshot.getChildren()) {
                    Cow vaca = snapshot1.getValue(Cow.class);
                    vaca.setNode_id(snapshot.getKey());
                    vacas.add(vaca);
                }
                adapter.notifyDataSetChanged();
            }

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

            }

        });

```

The rest of the code you told me, I did it as is, except in the `ref`, because if I don't add -- " " -- to the `node_id` it marks an error

`ref.child("node_id").updateChildren(updates)`

this keeps happening

[![enter image description here](https://i.stack.imgur.com/4IjX5.png)](https://i.stack.imgur.com/4IjX5.png)

**EDIT 4**

With this code i can get the `interno` value and edit it from the app. But now the problem is when I enter from the app to edit the `interno` value of a single node, it is changed in all nodes

```
private void Update() {
        DatabaseReference reference = FirebaseDatabase.getInstance().getReference();

        reference.child("Vacas").addListenerForSingleValueEvent(new ValueEventListener() {
            @Override
            public void onDataChange(@NonNull DataSnapshot snapshot) {
                for (DataSnapshot datas: snapshot.getChildren()){
                    String key = datas.getKey();

                    Map<String, Object> update = new HashMap<String, Object>();
                    update.put("interno", tvinterno.getText().toString());
                    FirebaseDatabase.getInstance().getReference().child("Vacas")
                            .child(key).updateChildren(update);
                }
            }

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

            }
        });
    }

```

[![enter image description here](https://i.stack.imgur.com/v2Lix.png)](https://i.stack.imgur.com/v2Lix.png)