Search code examples
androidstringapostrophe

Using ' in string.xml file


I have given app_name as below :

 <string name="app_name">My \'App</string>

to use apostrophe I used \ in it.

But, still it giving me below error:

Error:(2) Apostrophe not preceded by \ (in My 'App)

So, I removed ' from the app_name and write it as simply My App. But, still it giving me same error, I have restarted android studio, cleaned project and even restarted my system but,still getting same error.


Solution

  • Replace your line

     <string name="app_name">My \'App</string>
    

    with

     <string name="app_name">My &#39;App</string>