One String value is coming from my firebase:
if (task.isSuccessful()) {
// binding.contentMain.noData.setVisibility(View.GONE);
for (QueryDocumentSnapshot document : Objects.requireNonNull(task.getResult()))
postMap.putAll(document.getData());
try {
if (postMap != null)
//binding.desc1.setText(Objects.requireNonNull(postMap.get(CONTENT)).toString());
binding.desc1.setText(Html.fromHtml(Objects.requireNonNull(postMap.get(CONTENT)).toString()));
} catch (Exception e) {
e.printStackTrace();
}
}
Now, I'll tell you what is coming inside String from Firestore, Actually I only manually written as a String field inside Firestore collection.:
This is the first text. \n\n This is a second text. \n This is the third text. \n\n Done. \n
Make sure that above line is just one String/firestore field.
In firestore, I stored the above value as a String
, and fetching that value and showing it in Android. But it is not taking a new line. Instead, it is showing written \n along with other characters.
I tried with and without HTML. with \n and \r\n.
UPDATE: You can see below image how I stored in Firestore. https://drive.google.com/open?id=19yry9top_W8LREw5SEaZKWYWSlnCP1io