0

I have converted the selected text in my edittext to bold, Italic and now when i am storing it to sqllite DB it is not getting store in bold or italic form.

When i am retrieving the text it comes in normal form to textview (not in bold).

i have tried adding < b> before and after spannable but it is not working.

bold.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            //typeFaceSelected = Typeface.BOLD;
                            int startSelection = frontedit.getSelectionStart();
                            int endSelection = frontedit.getSelectionEnd();
                            if(startSelection>endSelection){

                                startSelection = frontedit.getSelectionEnd();
                                endSelection = frontedit.getSelectionStart();

                            }
                            Spannable s = frontedit.getText();
                            s.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), startSelection, endSelection, 0);
                            frontedit.setText(s);
                            frontedit.setSelection(startSelection, endSelection);
                        }

                    });

i dont know how to implement with html the bold, italic and normal font in edittext for selected text which will get store in sqllite DB and can be retrieved in same format (bold, italic). (if someone have code for this and share will be helpful)

Or

if someone is aware of how to store in sqllite db using spannable please help on above.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Ajinkya kadam
  • 542
  • 1
  • 6
  • 16
  • 1
    Possible duplicate of [Android Spannable text save/store issue](https://stackoverflow.com/questions/21444635/android-spannable-text-save-store-issue) – Fartab Sep 11 '19 at 11:29
  • Similar: https://stackoverflow.com/questions/49242955/is-it-possible-to-save-a-charsequence-in-firestore – Jemshit Sep 11 '19 at 11:33
  • it is giving me error on textview when i am writing like below ..... TextView frontv=findViewById(R.id.front_page_data); String getNewFrontContent=Html.toHtml(frontv.getText()); – Ajinkya kadam Sep 11 '19 at 11:51
  • Error : toHTML from android.text.spanned in HTML cannot be applied to (java.lang.Charsequence) – Ajinkya kadam Sep 11 '19 at 11:58

0 Answers0