Occasionally , we want to put a string with apostrophe (‘) or double-quotes(“) in our android strings.xml, but when you compile , you would get some error

<string name="guide1">Check your phone's battery</string>
<string name="guide2">He said "let's go"</string>

This would cause compile error, you must escape these characters:

  • apostrophe (‘) should be escaped by using \’
  • double-quotes(“) should be escaped by using \”

so ,the strings.xml should look like this:

<string name="guide1">Check your phone\'s battery</string>
<string name="guide2">He said \"let\'s go\"</string>

You can find detail android documents about the escaping here: