Skip to content Skip to sidebar Skip to footer

Com.google.firebase.database.databaseexception: Found Two Getters Or Fields With Conflicting Case Sensitivity For Property: User_name

This Code Gives Error While Extraction Data From the Firebase Database in the Line UsersForChat usersForChat = dataSnapshot.getValue(UsersForChat.class); com.google.firebase.dat

Solution 1:

If you are at the beginning of your project and you can make database changes, I recommend you changing all your field names, setters, and getters lower case according to Java Naming Convention.

Also, you need to change the visibility of all your fields from default access to private access like this:

privateString userName, userPhoneNo, userProfilePicUrl;

And the setters and getters like this:

publicvoidsetUserEmail(String userEmail) {this.userEmail = userEmail;}    
publicStringgetUserEmail() {return userEmail;}

publicStringgetUserPhoneNo() {return userPhoneNo;}
publicvoidsetUserPhoneNo(String userPhoneNo) {this.userPhoneNo = userPhoneNo;}

publicStringgetUserProfilePicUrl() {return userProfilePicUrl;}
publicvoidsetUserProfilePicUrl(String userProfilePicUrl) {this.userProfilePicUrl = userProfilePicUrl;}

As you probably see, only the setter, and getters have public access.

If you cannot change the names of the fields in your database then you need just to change the visibility of your fileds.

Solution 2:

When you make a POJO, it's customary to make all the fields private in order to force access through only the getters and setters.

privateString User_Name,User_PhoneNo,User_Profile_Pic_Url;

Also, traditionally, you don't use underscores in method names and members, just camel case. But I suppose that's up to you.

Post a Comment for "Com.google.firebase.database.databaseexception: Found Two Getters Or Fields With Conflicting Case Sensitivity For Property: User_name"