I wanted to highlight part of my edit text like so:-
mySpannablestring.setSpan((new
BackgroundColorSpan(color)),0,mySpannablestring.length(),0);
//then set to editext
editext.setText(mySpannablestring);
I saved it as a String to database using HTML :-
String todatabase = Html.toHtml(editext.getText());
//then saved the String in sqlite.
Basically the code saves for basic rich-text operations like bold,italic and underline but in that highlight operation it saved only on API 25 not even in API 23 .The intended text gets highlighted successfully but isn't saved .