ivan ivanov
ivan ivanov

Reputation: 21

Firebase - realtime database set additional value to user throws exception

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?

Upvotes: 1

Views: 558

Answers (1)

Khaled Lela
Khaled Lela

Reputation: 8119

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 Exception show that you have unsupported Collections object on User class just change with one of above supported type ex. List<Type>.

Update

Thanks to Alex Mamo 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<String, Object>

  • List

Upvotes: 1

Related Questions