gpt4 book ai didi

java - 不将自定义java对象保存在android studio的firebase中

转载 作者:行者123 更新时间:2023-12-01 23:35:52 24 4
gpt4 key购买 nike

mFirebaseAuth.createUserWithEmailAndPassword(email, pass).addOnCompleteListener(TeacherLogin.this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {

//getting current user and saving student info

try {
FirebaseUser user = mFirebaseAuth.getCurrentUser();
databaseReference = FirebaseDatabase.getInstance().getReference();
databaseReference.child(user.getUid()).push().setValue(teacherInfo);
Toast.makeText(TeacherLogin.this, "succesfully signup", Toast.LENGTH_SHORT).show();
}catch (Exception e) {
Log.e("Exception is", e.toString());
}

最佳答案

您必须像其他实体一样在 TeacherInfo 的 构造函数中添加子主题

    public TeacherInfo(String name, String department, String phone, String email, String password, ArrayList<String> subjects) { 
this.name = name;
this.department = department;
this.phone = phone;
this.email = email;
this.password = password;
this.subjects = subjects;
}

或者您必须为子实体实现Geter:Seter

关于java - 不将自定义java对象保存在android studio的firebase中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58277069/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com