< code >在此输入代码我在android应用程序中有一个注册表,用户可以在其中输入他们的详细信息。我尝试将数据存储到firebase中,数据正在存储,但问题是电话号码、年龄和姓名都将被存储。如何解决这个问题?请帮帮忙!
助手类
公共类UserHelperClass {
String fullName, city, age, disease, gender, bloodGroup, password, phoneNumber;
public UserHelperClass() {
}
public UserHelperClass(String fullName, String city, String age, String disease, String gender, String bloodGroup, String password, String phoneNumber) {
this.fullName = fullName;
this.city = city;
this.age = age;
this.disease = disease;
this.gender = gender;
this.bloodGroup = bloodGroup;
this.password = password;
this.phoneNumber = phoneNumber;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getDisease() {
return disease;
}
public void setDisease(String disease) {
this.disease = disease;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getBloodGroup() {
return bloodGroup;
}
public void setBloodGroup(String bloodGroup) {
this.bloodGroup = bloodGroup;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
}
数据存储到Firebase代码
rootNode=FirebaseDatabase.getInstance();
reference=rootNode.getReference("Users");
UserHelperClass helperClass=new UserHelperClass(fullName,city,age,phoneNumber,bloodGroup,age,disease,password);
reference.child(phoneNumber).setValue(helperClass);
从其他活动获取数据
phoneNumber = getIntent().getStringExtra("keynumber");
fullName = getIntent().getStringExtra("keyname");
city = getIntent().getStringExtra("keycity");
age = getIntent().getStringExtra("keyage");
disease = getIntent().getStringExtra("keydisease");
bloodGroup = getIntent().getStringExtra("keybloodgroup");
gender = getIntent().getStringExtra("keygender");
password = getIntent().getStringExtra("keypassword");
将数据传递给另一个活动
公共类注册活动扩展了应用程序兼容性活动 {
private AutoCompleteTextView dropDownText;
TextView titletext;
TextView chooegender;
TextView selectage;
TextInputLayout fullname, city, number, disease, password, bloodgroup;
RadioGroup radioGroup;
RadioButton selectedGender, radio1, radio2, radio3;
DatePicker datePicker;
CountryCodePicker countryCodePicker;
Button registerbtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
dropDownText = findViewById(R.id.dropdown_text);
titletext = findViewById(R.id.title_text);
chooegender = findViewById(R.id.choose_gender);
selectage = findViewById(R.id.select_age);
fullname = findViewById(R.id.name);
city = findViewById(R.id.city);
number = findViewById(R.id.number);
countryCodePicker = findViewById(R.id.country_code_picker);
disease = findViewById(R.id.disease);
bloodgroup = findViewById(R.id.bloodgroup);
password = findViewById(R.id.password);
radio1 = findViewById(R.id.radioButton1);
radio2 = findViewById(R.id.radioButton2);
radio3 = findViewById(R.id.radioButton3);
radioGroup = findViewById(R.id.radiogroup);
datePicker = findViewById(R.id.age_picker);
selectedGender = findViewById(radioGroup.getCheckedRadioButtonId());
registerbtn = findViewById(R.id.register);
String[] item = new String[]{
"A+Ve",
"A-Ve",
"B+Ve",
"B-Ve",
"AB+Ve",
"AB-Ve",
"O+Ve",
"O-Ve"
};
ArrayAdapter<String> adapter = new ArrayAdapter<>(
RegisterActivity.this,
R.layout.dropdown_item,
item
);
dropDownText.setAdapter(adapter);
}
public void callotpverificationscreen(View view) {
if (!validateFullname() | !validateCity() | !validateDisease() | !validateNumber() | !validatePassword() | !validateGender() | !validateAge())
return;
selectedGender = findViewById(radioGroup.getCheckedRadioButtonId());
String _gender = selectedGender.getText().toString().trim();
int day = datePicker.getDayOfMonth();
int month = datePicker.getMonth();
int year = datePicker.getYear();
String Age = day + "/" + month + "/" + year;
String FullName = fullname.getEditText().getText().toString();
String City = city.getEditText().getText().toString().trim();
String Disease = disease.getEditText().getText().toString().trim();
String Blood_group = bloodgroup.getEditText().getText().toString().trim();
String code = countryCodePicker.getSelectedCountryCodeWithPlus();
String Number = number.getEditText().getText().toString().trim();
String CompletePhoneNumber = "+" + countryCodePicker.getFullNumber() + Number;
String Password = password.getEditText().getText().toString().trim();
Intent intent = new Intent(getApplicationContext(), OTP_verification.class);
intent.putExtra("keyname", FullName);
intent.putExtra("keycity", City);
intent.putExtra("keyage", Age);
intent.putExtra("keydisease", Disease);
intent.putExtra("keybloodgroup", Blood_group);
intent.putExtra("keynumber", CompletePhoneNumber);
intent.putExtra("keypassword", Password);
intent.putExtra("keygender", _gender);
startActivity(intent);
}
火基数据库图像(https://i.stack.imgur.com/YYoYt.jpg)
创建新的UserHelperClass时,您将字符串的顺序放错了。所以:
UserHelperClass helperClass = new UserHelperClass(fullName, city, age, disease, gender, bloodGroup, password, phoneNumber);
而不是
UserHelperClass helperClass = new UserHelperClass(fullName,city,age,phoneNumber,bloodGroup,age,disease,password);
您没有遵循正确的顺序,如UserHelperClass:您应该遵循以下格式:
fullName, city, age, disease, gender, bloodGroup, password, phoneNumber
但是您在调用类时使用了错误的顺序。使用此格式
UserHelperClass helperClass=new UserHelperClass(fullName, city, age, disease, gender, bloodGroup, password, phoneNumber);
尽管如此:
UserHelperClass helperClass=new UserHelperClass(fullName,city,age,phoneNumber,bloodGroup,age,disease,password);
所以我试图将一些数据存储到我的实时数据库中。我目前有两个独立的视图控制器,一个用于用户注册,另一个用于用户选择其配置文件图像并能够更改该图像。在注册页面上,我将“用户名”保存到firebase,如下所示: 对于个人资料图像,我有这样保存的数据 我希望这两个数据都保存在“用户”下-
问题内容: 我通过使用将JodaTime 字段存储到列中。应用服务器的时区为+4。数据库服务器+9时区。会导致+9是时区(正确值为)。 我还没有找到任何相关主题。正确存储。 域对象具有以下映射属性: 如何正确存储DateTime? 问题答案: 好。我已经花了8个小时来解决问题。如果您使用用户类型项目来保留JodaTime,则必须将class 属性设置为等于当前应用程序服务器时区(不是数据库!)。
日志条目:10:25 运营:08:25
我在数据库中有数据:Firebase中的数据库 我想读取所有子项(Belgia、Czechy、Polska…),并将其显示在文本字段中,但单击按钮后(我不会更改数据库中的数据)。按钮分配了以下功能: 在我写代码之前: 不幸的是,当我按下按钮时,什么也没有发生。 我很感激你的帮助问候,马辛
问题内容: 运行我的Android应用程序时出现此错误: 在类[[Lmodel.Vak;中,没有字段具有DatabaseField注释。 我的班级Vak有注解,所以我真的不明白为什么它仍然给我这个错误。 我有一个名为Databasehelper.java的文件,在其中扩展了OrmLiteSqLiteOpenHelper,该文件如下所示: 我还有一个扩展OrmLiteBaseActivity的文件控
我创建了一个TextView,它以多行显示值 ,我希望将该值保留在SQLite数据库中。这是我使用的代码: 问题是当我保存值时,整个值被插入到一个单元格中。我希望每行的值分开,然后插入到每行的单个单元格中,尽管我使用扫描器方法插入数据,但它不起作用。那有什么办法吗?