Kv-z icon indicating copy to clipboard operation
Kv-z copied to clipboard

insert questions and answers in the firebase?

Open sahujaunpuri opened this issue 5 years ago • 3 comments

How to insert questions and answers in the firebase? Can anyone explain it to anyone?

sahujaunpuri avatar Mar 05 '19 13:03 sahujaunpuri

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.

Agnohendrix avatar Mar 05 '19 15:03 Agnohendrix

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

sahujaunpuri avatar Mar 06 '19 07:03 sahujaunpuri

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).

Agnohendrix avatar Mar 06 '19 13:03 Agnohendrix