【发布时间】:2014-03-02 10:04:53
【问题描述】:
我想将它插入到我的表中的歌曲名称包含一个“'”(撇号)所以,执行请求时会出错。我该如何解决它
Cursor pid = mDB.rawQuery("select Id FROM MusicPlayer WHERE "Path ='" + sname + "';", null);
我得到了 sname 运行时所以 .. sname=/mnt/sdcard/Now Thats What I Call Music 85 [Bubanee]/16 - Let's Get Ready To Rhumble (100% Radio Mix) - PJ & Duncan.mp3
我得到以下错误..
android.database.sqlite.SQLiteException: near "s": syntax error: , while compiling: SELECT Id FROM MusicPlayer WHERE Path ='/mnt/sdcard/Now Thats What I Call Music 85 [Bubanee]/16 - Let's Get Ready To Rhumble (100% Radio Mix) - PJ & Duncan.mp3';
因为 sname 包含 let's 单词和 ' 这给了我错误。
【问题讨论】:
-
省略撇号
-
@RaghavSood 我怎么能逃脱。我得到它运行时..再次转义后,另一个字符串可能有撇号
标签: android sqlite cursor sqliteopenhelper