Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escaping single quotes in resource xml for Android

I have a file with strings in my ../res/values/strings.xml, which I try to source for my project. This works fine with normal texts. Problem : I have single quotes in my texts and I try to escape them. Many sources suggest to escape it with ' in XML Files.

But this does not work for me in my Eclipse Android Project. When I do a clean project, it shows errors in my Code. (R.class)

<string name="mystring_id">&apos;Hello&apos;</string>

Howto escape properly ?

like image 322
mcfly soft Avatar asked Aug 14 '14 15:08

mcfly soft


3 Answers

You can use \' in your string resources.

like image 192
Karakuri Avatar answered Oct 17 '22 03:10

Karakuri


Use double quotes:

<string name="mystring_id">"'Hello'"</string>
like image 27
Simon Marquis Avatar answered Oct 17 '22 03:10

Simon Marquis


you need to escape the apostrophe by using

\ before '

etc didn't should be like

didn\'t
like image 25
Bilal Shahid Avatar answered Oct 17 '22 04:10

Bilal Shahid