"how to add data to the existing database in a firebase realtime database?" Code Answer

2

this line string key = databasereference.push().getkey(); creates a new unique reference, that you then write to. if you want to write to an existing reference, you'll need to know the key of that reference, typically by reading it from the ui item that the user clicked on.

note that calling setvalue() replaces all data at the location. if you want to update a subset of the data, or add new properties, you will either have to call setvalue() on a lower level, or call updatechildren().

so for example:

databasereference.child(anahtar).child("urunyorum/newproperty").setvalue(urunler);

or:

map<string,object> values = new hashmap<string,object>();
values.put("kisiid", kisiid);
values.put("kisiad", kisiad);
databasereference.child(anahtar).child("urunyorum").updatechildren(values);
By Andrew.T on September 18 2022

Answers related to “how to add data to the existing database in a firebase realtime database?”

Only authorized users can answer the Search term. Please sign in first, or register a free account.