我正在尝试解决一个问题,我正在尝试使用我的应用注册新用户,没有收到任何错误消息,但是新用户未出现在数据库中,这是我注册活动的代码:>
//check if user already exists
if (dataSnapshot.child(regLogin.getText().toString()).exists()) {
showMessage("user name already taken!");
btnRegConfirm.setVisibility(View.VISIBLE);
progressBarRegister.setVisibility(View.INVISIBLE);
}
else{
User newUser = new User(regEmail.getText().toString(), regPassword1.getText().toString(), regPhone.getText().toString(), regFirstName.getText().toString());
table_user.child(regLogin.getText().toString()).setValue(newUser);
showMessage("Registration Completed!");
finish();
}
这是我的用户类别的代码:
package com.example.danie.dine.Model;
public class User {
private String email;
private String firstName;
private String login;
private String password1;
private String phone;
public User() {
}
public User(String email, String password1, String phone, String name) {
email = email;
password1 = password1;
name = firstName;
phone = phone;
login = login;
}
public String getEmail() {
return email;
}
public void setEmail(String regEmail) {
this.email = email;
}
public String getName() {
return firstName;
}
public void setName(String name) {
this.firstName = firstName;
}
public String getPassword() {
return password1;
}
public void setPassword(String password) {
this.password1 = password;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
}
任何帮助将不胜感激 在数据库中将读写设置为true
数据库结构:
{
"User": {
"daniel86": {
"firstName": "daniel",
"email": "daniel@test.com",
"phone": "+123123123",
"password": "123456"
},
"admin2018": {
"firstName": "admin",
"email": "admin@test.com",
"phone": "+123123123",
"password": "000111"
}
}
}
答案 0 :(得分:0)
刚刚找到了解决方案...
问题出在我的User类(getter和setter)上 因此,我没有像以前的代码片段那样使用用户构造函数,而是这样做了:
dbms_output.put_line
}
现在一切都很好!