I have been trying to create my first Android App in which, the users enter many properties of their children, for each child, example :
(name, age, height, weight, gender)
The user can add many entries, and for each child, when he fills the rows and clicks send, the entry goes from his phone (app) to my database.
Can we do this with firebase ? Any help could help me !
After the user enters his information then use setValue()
to send the data to the database:
String name=editText.getText().toString();
int age=Integer.valueOf(editAge.getText().toString());
String gender=editGender.getText().toString();
FirebaseUser user=FirebaseAuth.getInstance().getCurrentUser();
String userId=user.getUid();
DatabaseReference ref=FirebaseDatabase.getInstance().getReference("user").child(userId);
ref.child("name").setValue(name);
ref.child("age").setValue(age);
ref.child("gender").setValue(gender);
You can retrieve the userid, if you are using firebase authentication. If you did not use it then instead of child(userId)
write push()
After you do the following you will have this database:
user
userId
name: your_name
age: your_age
gender: your_gender