"how to add new child in firebase database android" Code Answer

5

you'll need to call push() to generate a unique key for the new data:

databasereference mdatabase = firebasedatabase.getinstance().getreference() 
mdatabase.push().setvalue(1);

this will append the new value at the end of the list.

by combining the push() and child() methods, you can create multiple lists of children in the database:

mdatabase.child("numbers").push().setvalue(1);
mdatabase.child("numbers").push().setvalue(53);
mdatabase.child("numbers").push().setvalue(42);

mdatabase.child("letters").push().setvalue("a");
mdatabase.child("letters").push().setvalue("z");
mdatabase.child("letters").push().setvalue("c");

see the section append to a list of data in the firebase documentation.

By Anderson Silva on May 28 2022

Answers related to “how to add new child in firebase database android”

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