问题
I have class User which has additional info, but it is throwing:
com.google.firebase.database.DatabaseException: Serializing Collections is not supported, please use Lists instead
My code is:
User user = new User(Gender.valueOf(mGenderSpinner.getSelectedItem().toString()));
Log.d("GENDER", user.getGender().toString());
mFirebaseDatabase.getReference("Users")
.child(mAuth.getCurrentUser().getUid())
.setValue(user)
The question is how I can still set User.class value or this is not possible?
回答1:
Value type ordering
- Null values
- Boolean values
- Integer and floating-point values, sorted in numerical order
- Date values
- Text string values
- Byte values
- Cloud Firestore references
- Geographical point values
- Array values
- Map values
com.google.firebase.database.DatabaseException: Serializing Collections is not supported, please use Lists instead
- Above
Exceptionshow that you have unsupportedCollectionsobject on User class just change with one of above supported type ex.List<Type>.
Update
Thanks to Alex Mano comment,
Above is Data Types is for Firebase Cloud Database, But Firebase Realtime Database as following.
Pass types that correspond to the available JSON types as follows:
- String
- Long
- Double
- Boolean
- Map
- List
来源:https://stackoverflow.com/questions/51813160/firebase-realtime-database-set-additional-value-to-user-throws-exception