0

I've searched a lot around S.O. but never found an answer, so I post a question here:

I'm developing an Android App (Italian Language) and when I call an SQL Insert Function the App crashes because of an apostrophe character inside the text, like this:

db.execSQL("INSERT INTO Famiglia (Description) VALUES ('Quando il sole s'allontana la vita diviene più sana')");

I tried to escape the word s'allontana so that it becomes s\'allontana but this isn't working.

Really dunno what to do...

Ale TheFe
  • 633
  • 9
  • 25

1 Answers1

1

Single quotes are escaped by typing them twice. Like:

db.execSQL("INSERT INTO Famiglia (Description) VALUES ('Quando il sole s''allontana la vita diviene più sana')");
Gurwinder Singh
  • 35,652
  • 5
  • 39
  • 62