Amorgos Amorgos - 1 month ago 11
Android Question

How to put a “-” in string.xml file, but without escaping

I have a configuration.xml file which I hold all the (yep, you guessed it!).. configuration strings and values and stuff.

One of those values is a string which is an oauth client id, and it has a hyphen..

<string name="server_clientid">5467656-blahblahblah.apps.googleusercontent.com</string>


Now I get the warning message..

Replace "-" with an "en dash" character (–, &#8211;) ?


Ok fair enough, but if I escape with this then the client id is not valid when I fetch it within the app. I can't use & #8211; basically. How do I get around this?

Answer

You wrap your values in

<![CDATA[ ]]> 

which stops the parser from parsing the contents. E.g.

<string name="server_clientid"><![CDATA[ 5467656-blahblahblah.apps.googleusercontent.com ]]></string>