I have a string in my strings.xml in which there is "\n" sign between them
<string name="example">Hello\nworld</string>
What can I do to get the "\n" sign instead of a new line?
I have a string in my strings.xml in which there is "\n" sign between them
<string name="example">Hello\nworld</string>
What can I do to get the "\n" sign instead of a new line?
Special characters in string resources can be backslash-escaped. So if you want to display "Hello\nworld" then you should make your string be hello\\nworld
(notice the double backslash).
In Code
String string = "abcd\nddsda";
System.out.println(string.replace("\n","\\n"));