0

enter image description here

Hi guys, I'm new to firebase. Hopefully, some expert or guru in Firebase could give me help in solving this problem. Thank you!

Plan to save data in yellow highlight to blue highlight

Final Result as duration, info, time, matricno, password under one push id

First Activity Code (Attempt action with blue highlight)

FirebaseDatabase db = FirebaseDatabase.getInstance();

DatabaseReference myRef = db.getReference("Class Information");

String key = myRef.push().getKey();

myRef.child(uid).child("Student Attend").child(key).setValue(classInformation);

Second Activity Code (Attempt action with yellow highlight)


DatabaseReference myRef = abRef.push();

String key = myRef.push().getKey();

DatabaseReference abRef = myRef.child(uid).child("Student Attend").child(key);

abRef.setValue(student);
Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
Jodan
  • 13
  • 1
  • 4

1 Answers1

0

Every time you are using DatabaseReference's push() method using:

String key = myRef.push().getKey();

A brand new random key is generated. If you want to use the key that is generated in your first activity, in the second activity, you should send it through an Intent or a Bundle and not generate it again.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193