mcfly soft
mcfly soft

Reputation: 11655

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 ?

Upvotes: 24

Views: 16316

Answers (4)

digi travel
digi travel

Reputation: 1

 <string name="forgot_password_body" tools:ignore="StringEscaping">Mother's name</string>

using {tools:ignore="StringEscaping"} this tools attribute you can add single quote like you want

Upvotes: -1

Bilal Shahid
Bilal Shahid

Reputation: 490

you need to escape the apostrophe by using

\ before '

etc didn't should be like

didn\'t

Upvotes: 5

Simon Marquis
Simon Marquis

Reputation: 7526

Use double quotes:

<string name="mystring_id">"'Hello'"</string>

Upvotes: 11

Karakuri
Karakuri

Reputation: 38605

You can use \' in your string resources.

Upvotes: 42

Related Questions