2016-09-15 62 views
0

出了什麼問題?存儲在firebase數據庫中的數據都是錯誤的,這與我在EditTexts中的輸入完全不同。爲什麼在firebase中存儲了錯誤的數據android

public void createToUserProfile(){ 
     String firstName = etFirstName.toString().trim(); 
     String lastName = etLastName.toString().trim(); 
     String mobilePhoneNumber = etMobilePhoneNumber.toString().trim(); 
     String iDNumber = etIDNumber.toString().trim(); 
     String year = etYear.toString().trim(); 
     String month = etMonth.toString().trim(); 
     String day = etDay.toString().trim(); 
     String dateOfBirth = year+"/"+month+"/"+day; 
     String country = etCountry.toString().trim(); 
     String province = etProvince.toString().trim(); 
     String city = etCity.toString().trim(); 
     String postCode = etPostCode.toString().trim(); 
     String address = etAddress.toString().trim(); 

     Firebase ref = new Firebase(Config.USER_URL); 
     UserP newUser = new UserP(); 

     newUser.setFirstName(firstName); 
     newUser.setLastName(lastName); 
     newUser.setMobilePhoneNumber(mobilePhoneNumber); 
     newUser.setiDNumber(iDNumber); 
     newUser.setDateOfBirth(dateOfBirth); 
     newUser.setCountry(country); 
     newUser.setProvince(province); 
     newUser.setCity(city); 
     newUser.setPostCode(postCode); 
     newUser.setAddress(address); 
     ref.child("UserP").setValue(newUser); 
} 

的火力地堡控制檯存儲的數據顯示如下: Data stored wrong in Firebase Database

回答

1

我記得這個同樣的問題從一前一後你的事。

一個EditText有一個toString()方法從View繼承,該方法返回視圖屬性的字符串轉儲。你錯誤地稱之爲。要獲取EditText包含的字符串,您需要撥打getText().toString()

+0

非常感謝!問題解決了。 –

相關問題