-2

The problem itself is more complex than the question makes it seem, at least to me.

My database looks like this:

database

The problem is that I am fairly new to using Firebase for my android app and I do not know how to add an entirely new User profile here. For example, if someone were to register, and it would then add a new "record" at "2" and so on. How do you do this?

PradyumanDixit
  • 2,372
  • 2
  • 12
  • 20
  • You can also check **[this](https://stackoverflow.com/questions/49253026/firebase-auth-and-database/49256810)** out. – Alex Mamo Nov 05 '18 at 08:28

1 Answers1

1

It depends on the way you're storing the data. If you have a class with all of your values in the object of it, then you can use a code like this to do so:

DatabaseReference ref = FirebaseDatabase.getInstance().getReference().child("userTable");
// where User is your class and user is it's object with the values you need to update
ref.child(user.getNumber()).setValue(user);

If you don't have a class like that and you need to set those values, then you'd have to do it individually to every node of your database, with a code like this:

DatabaseReference refNew = FirebaseDatabase.getInstance().getReference().child("userTable").child(i);

// where i is the variable which you have to keep count of your users

ref.child("Age").setValue(age);
ref.child("Company").setValue(company); // and so on

// age, company are variable with values you want to store
PradyumanDixit
  • 2,372
  • 2
  • 12
  • 20