我有一个 User 类,它有额外的信息,但它正在抛出:
com.google.firebase.database.DatabaseException: Serializing Collections is not supported, please use Lists instead
我的代码是:
User user = new User(Gender.valueOf(mGenderSpinner.getSelectedItem().toString()));
Log.d("GENDER", user.getGender().toString());
mFirebaseDatabase.getReference("Users")
.child(mAuth.getCurrentUser().getUid())
.setValue(user)
问题是我如何仍然可以设置 User.class 值或者这是不可能的?
最佳答案
- 空值
- boolean 值
- 整数和浮点值,按数字顺序排序
- 日期值
- 文本字符串值
- 字节值
- Cloud Firestore 引用资料
- 地理点值
- 数组值
- 映射值
com.google.firebase.database.DatabaseException: Serializing Collections is not supported, please use Lists instead
- 以上
Exception
表明你不支持Collections
User 类上的对象只需更改为上述支持的类型之一。List<Type>
.
更新
感谢Alex Mamo评论,
以上是针对 Firebase 的数据类型 Cloud Database , 但是 Firebase Realtime Database如下。
与可用 JSON types 对应的传递类型如下:
字符串
长
双
boolean 值
map <字符串,对象>
列表
关于java - Firebase - 实时数据库为用户抛出异常设置附加值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51813160/