问题描述
是否可以将 CharSequence
变量保存到 Firebase
中?
Is possible to save a CharSequence
variable into Firebase
?
已检出:支持的数据类型,但字符序列
不存在...
Checked out: Supported Data Types, but charsequence
is not there...
我遇到了与此相关的可序列化问题,尝试过:护卫规则,公共属性,实现可序列化等;但是我无法将字符序列
保存到 Firebase
中.
I'm getting serializable problems related to this, tried: pro-guard rules, public attributes, implements serializable, etc; but I'm not able to save charsequence
into Firebase
.
有人能帮助我吗?
PS:它必须是 字符序列
,而不是字符串!
推荐答案
您可以将CharSequence保存为Firestore,方法是使用其 toString()方法.如果您从Firestore中读回字符串,它将是一个String对象,该对象也实现CharSequence.您将无法通过CharSequence接口使用自动序列化.当您读回数据时,SDK将不知道要为您创建CharSequence的哪种实现.
You can save a CharSequence to Firestore by converting it to a String with its toString() method. If you read the string back from Firestore, it will be a String object, which implements CharSequence as well. You will not be able to use automatic serialization with a CharSequence interface. The SDK won't know which implementation of CharSequence to create for you when you read the data back out.
这篇关于是否可以在Firestore中保存CharSequence?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!