在sqlite中更新表时发生错误

Muk*_*und 0 sqlite android

String updateQuery = "UPDATE Bookdetails SET lastchapter = " + test + " WHERE bookpath=" +sentFilename; 
db.execSQL(updateQuery);
Run Code Online (Sandbox Code Playgroud)

错误:

03-04 13:36:23.997: I/System.out(9722): android.database.sqlite.SQLiteException: 
near "/": syntax error: , while compiling: UPDATE Bookdetails SET lastchapter = 
mukund WHERE bookpath=/mnt/sdcard/Download/What's so great about the doctrine of 
 grace.epub errors happens
Run Code Online (Sandbox Code Playgroud)

错误发布在上面

我的表包含字段id,bookpath和lastchapter,book path包含值

 /mnt/sdcard/Download/What's so great about the doctrine of grace.epub  
  /mnt/sdcard/Download/1b4fdaac-f31d-41e8-9d15-26c9078d891f.epub 
  /mnt/sdcard/Download/Commentary on Romans.epub
Run Code Online (Sandbox Code Playgroud)

而lastchapter包含的价值一无所有

id包含1 2 3

为什么"/"在我的更新查询中没有哈希发生的错误只存在于存储bookpath的字符串?这是一个错误吗?

laa*_*lto 6

SQL中的字符串文字需要用''引号括起来.

但是,最好使用这样的?文字占位符:

String updateQuery = "UPDATE Bookdetails SET lastchapter=? WHERE bookpath=?";
db.execSQL(updateQuery, new String[] { test, sentFilename });
Run Code Online (Sandbox Code Playgroud)