How can insert Cutout sign ( ' ) sqlite database from a txt file

54 Views Asked by At

I used sqlite database to save my data. I backuped sqlite table to a txt file. When I try to restore from txt to sqlite I get syntax error (code-1) . Because I used cutout sign ( ' ) for example when I writing (Türk'ler geldi).

Error is : android.database.sqlite.SQLiteException: near "ler": syntax error (code 1): , while compiling: .......

How can I insert it. I used ( \' ) but it didn't work.

Here is my code from sqlite to txt file

semptoms = db.allSemptom();
int say = semptoms.size();
StringBuilder message = new StringBuilder("");
  for (int i = 0; i < say; i++) {
Semptom semptom = semptoms.get(i);
String name = semptom.getName();
message.append(name + "\n"); 
  }
saveToSymptom(message.toString());

I try to add .replace(" ' "," \ ' ") but didn't work

I mean like this

message.append(name.replace(" ' "," \ ' ") + "\n")
1

There are 1 best solutions below

0
On BEST ANSWER

Thanks to forpas for this answer I used the below code and now problem solved. message.append(name.replace("'","''") + "\n") as forpas said in comment