SpannableStringBuilder cannot be cast to android.text.SpannableString <p>I need to save data from <code>TextView</code> to and SQLite database in HTML format.</p> <p>I'm using this code to convert text from <code>TextView</code> to HTML-formatted string:</p> <pre><code>public static String htmlToString(TextView textview) { SpannableString contentText = (SpannableString) textview.getText(); return Html.toHtml(contentText).toString(); } </code></pre> <p>However, I get this error:</p> <blockquote> <p>05-05 17:01:37.033: E/AndroidRuntime(14295): java.lang.ClassCastException: android.text.SpannableStringBuilder cannot be cast to android.text.SpannableString</p> </blockquote> <p>How can I fix this?</p>