XML within an Android string resource?

Olical picture Olical · Dec 20, 2010 · Viewed 24.6k times · Source

I was wondering if I could place XML within /res/values/strings.xml? I ask this because I am checking for the XML data file for my application, if it does not exist yet then it creates it from the default contents that will be contained as a string resource.

Eclipse tries to change the less than and greater than tags to their corresponding HTML entities when using the GUI to edit the strings. Is eclipse on the right track? Because I should think that it will be written out into my file as HTML entities too. Could I use getText() rather than getString() to convert the entities back into tags?

Answer

Alexander Stolz picture Alexander Stolz · Dec 20, 2010

Yes you can, just use CDATA

<string name="stringName1"><![CDATA[<html>bla</html>]]></string>