如何使用 Sharedpreferences 存储 EditText 样式(粗体、斜体、颜色等)

How to store the EditText style (Bold, Italic, Color, etc.) using Sharedpreferences

请谁告诉我 如何使用 SharedPreferences 通过(粗体、斜体、颜色等)在 EditText 中保存 text selected

这是我的代码:

int selectionStart = editTxt.getSelectionStart();    
int selectionEnd = editTxt.getSelectionEnd();                                
SpannableStringBuilder  stringBuilder = (SpannableStringBuilder) editTxt.getText();   
TextAppearanceSpan styleRed_Bold = new TextAppearanceSpan(getBaseContext(), R.style.CustomStyle);                                             stringBuilder.setSpan(styleRed_Bold , selectionStart , selectionEnd , 0);
SharedPreferences pref = getApplicationContext().getSharedPreferences("MyPref", 0); 

Editor editor = pref.edit();

editor.putString("edittext", "text of your edit text"); 

editor.putString("style", "bold"); 

editor.apply