如何设置我的领域对象的标识符..我需要在我的Android应用程序的第二个活动中使用它进行查询。感谢。
学校对象:
public class School extends RealmObject {
@Required
private String SchoolID;
private String SchoolName;
private RealmList<Student> Students;
getters/setters
public RealmList<Student> getStudents() {
return Students;
}
public void setStudents(RealmList<Student> students) {
Students = students;
}
学生对象:
public class Student extends RealmObject{
@Required
private String StudentID;
private String StudentName;
getters/setters
}
答案 0 :(得分:0)
您可以使用@PrimaryKey
:https://realm.io/docs/java/latest/#primary-keys
public class Student extends RealmObject {
@PrimaryKey
private String StudentID;
private String StudentName;
// getters/setters
}