Firebase-实时数据库为用户设置附加值引发异常 [英] Firebase - realtime database set additional value to user throws exception
本文介绍了Firebase-实时数据库为用户设置附加值引发异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有User类,它具有其他信息,但它抛出:
I have class User which has additional info, but it is throwing:
com.google.firebase.database.DatabaseException:不支持序列化集合,请改用列表
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值,或者这是不可能的?
The question is how I can still set User.class value or this is not possible?
推荐答案
Value type ordering
- 空值
- 布尔值
- 整数和浮点值,按数字顺序排序
- 日期值
- 文本字符串值
- 字节值
- Cloud Firestore参考
- 地理点值
- 数组值
- 地图值
- 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
-
Exception
之上,表明您在User类上具有不受支持的Collections
对象,只需将其更改为上述支持的类型ex之一即可.List<Type>
. - Above
Exception
show that you have unsupportedCollections
object on User class just change with one of above supported type ex.List<Type>
. Above is Data Types is for Firebase Cloud Database, But Firebase Realtime Database as following.
- 字符串
- 长
- Double
- 布尔值
- 地图
- 列表
更新
感谢 Alex Mano 评论,
Thanks to Alex Mano comment,
与可用的 JSON类型如下:
这篇关于Firebase-实时数据库为用户设置附加值引发异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文