I tried this and it gave me a decent results
afer you paste the text in EditText
final    String keepFormat=TextUtils.htmlEncode(mytext.getText()+"");
//-------------------------------------------------------
to receive it from Firebase let's say you gonna set this text to a
TextView textView;
    textView.setText(TextUtils.htmlEncode( aboutString));
//---------------------------------------------------------------
if you take a look at the Firebase Realtime database console you will notice that your text has extra code in it to fill the spaces and keep the text format the same way it was in the EditText