0

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")
4

1 回答 1

0

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

于 2019-05-23T21:53:59.273 回答