问题
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