Kv-z
Kv-z copied to clipboard
insert questions and answers in the firebase?
How to insert questions and answers in the firebase? Can anyone explain it to anyone?
Hi, i've seen we're creating the same app, LoL. However, you can add it manually to your database or you could create a class Question, filled with all the fields you need and then load it as a child to your Firebase Database, just like you do with Users and Scores.
However, you can add it manually to your database
That's is my real question.
I am confused in understanding his counterpart (Model). What's the name of its column
You have your class Question, which contains all the fields you need to load into your database. Now you can create an activity which creates a new Question() newQuestion.
This activity connects to your db and to the reference of all Questions listed:
questions = FirebaseDatabase.getInstance().getReference("Questions");
Then you add Question object to your Questions list(questions):
questions.child(chooseAQuestionName).setValue(newQuestion);
The name of the column question is set by you, just choose one. (Same story for Question name).