5

In my strings.xml, I have made a string containing (it's) and I get this error.

Error:(218) Apostrophe not preceded by \

Yes, I know I have to either place a \ before the apostrophe, or just delete the apostrophe, but my problem is that when I run the app using (it\s) or just deleting it, it comes back; even if I delete the whole string, it all comes back when I click run. How do I stop this?

Here's the String but it really doesn't matter. I just want it to be deleted and not restored when I run the app.

<string> name="talk" So, you want these things? LOL its gonna</string>
Pang
  • 9,564
  • 146
  • 81
  • 122
John Westlen
  • 51
  • 1
  • 3
  • what do you mean `it comes back`? is someone or something manipulating your files without your knowledge? – njzk2 Feb 24 '16 at 02:17
  • 4
    Nevermind, i wasn't being observant, forgive me i'm new to programming, it showed me the error in the values.xml, thinking i was in the string.xml, it fixed once i went to the right file. – John Westlen Feb 24 '16 at 09:37
  • 1
    John Westlen make this an answer and I will upvote it, this is the exact solution to my problem. – Blaasd Jul 17 '16 at 16:06

4 Answers4

9

When the error occurs, Android Studio opens the values.xml which, at that point in the file, deceptively looks exactly the same as your strings.xml. Make sure you're updating the strings.xml and you should be good to go.

David
  • 834
  • 1
  • 10
  • 27
2

Actually, there are two files strings.xml and values.xml

We edit our string data in strings.xml and whenever we getting the error like Apostrophe not preceded by \, When you click on error android studio redirect you to values.xml and you are editing in values.xml and android studio just deleted what you edited.

So make sure you are editing strings.xml not values.xml

Puneet Verma
  • 1,373
  • 2
  • 19
  • 23
1

Place your string in double quotes.<string>"Your text 'here'"</string>

Jeffrey Nyauke
  • 1,846
  • 14
  • 12
0

try

<string name="talk">your string value</string>