Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
128 views
in Technique[技术] by (71.8m points)

java - Is there a way to store Key in class which I cast from Firebase object?

This is my database :

[x] database
-- > [+] students
-----> [+] -KuGacomJymBwkcc7zlU (pushKey)
-----------> Name - Jon
-----------> Age - 21

I have Student.class :

String name;
String age;

public Student(String Name, String Age) {
this.name=Name;
this.age=Age;
}

I read the information from firebase datasnapshot like this:

Student newStudent = DataSnapshot.getValue(Student.class);

When I do this I get the name and the age, but my question if there is a way to store the ID (pushKey) on the Student class without adding a String that will hold it and take another field on the firebase database.

Thank you all.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...