Is it possible to save a CharSequence in Firestore?

心不动则不痛 提交于 2019-12-14 02:28:02

问题


Is possible to save a CharSequence variable into Firebase?

Checked out: Supported Data Types, but charsequence is not there...

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.

Is anyone able to help me out with this?

PS: it needs to be a charsequence, not a string!


回答1:


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.




回答2:


To store markup text(or CharSequence) in database(may be Firestore) you may use Html.toHtml(Spanned text) function from android.text.Html class which return styled html string. To retrieve markup text back use Html.fromHtml(String html). You may find android reference here.



来源:https://stackoverflow.com/questions/49242955/is-it-possible-to-save-a-charsequence-in-firestore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!