How to write & (ampersand) character in Android string resource

How to write & (ampersand) character in Android string resource

Because ampersand or & character break the xml validation in Android string.xml file if you need to insert a text with ampersand you have to encode it like in HTML encode.

 

<string name="mystring">This is my test & example</string> <!-- this is not ok -->

correct wayWatch movie online Get Out (2017)Watch movie online The Lego Batman Movie (2017)


<string name="mystring">This is my test &amp; example</string> <!-- this is not ok -->

No comments.