Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+15 votes

So I have an ArrayList of objects that I need to be able to add to firebase when a new element is added to the ArrayList or an element in the ArrayList is changed. How would I push these changes up to firebase?

asked in CSC490_Spring2019 by (1 point)

2 Answers

+6 votes
 
Best answer

Ended up finding an answer here
//https://firebase.google.com/docs/database/web/read-and-write

Need a database reference
DatabaseReference database=FirebaseDatabase.getInstance().getReference(key);
Then put
database.child(key).setValue(value);
Where key is the name of your variable and value is the value of your variable you are storing

answered by (1 point)
selected by
+3 votes

Expanding on Jared's answer, the command database.child(key).push().setValue(value); will add an additional value without replacing the data that is there. If you want to set that child to have a singular value, leave out the .push()

answered by (1 point)
...