0
我努力在我的表刪除行:刪除SQLite數據庫中的項目,而不id字段
String createQuery3 = "CREATE TABLE foto" +
"(_id integer primary key autoincrement," +
"_id_visita integer, nome_immagine TEXT, nome_immagine_resampled TEXT, " +
"commento_foto TEXT," + "commento_foto_resampled TEXT," +
"FOREIGN KEY(_id_visita) REFERENCES visite (_id));";
通過線:
public void cancellaFoto(Long idPaziente, String nomeFoto) {
// TODO Auto-generated method stub
databaseConnector.open(); // open the database
database = databaseConnector.getOpenDatabase();
Log.d(TAG, "FOTO SINGOLA DA CANCELLARE ID_Paziente: " + idPaziente);
Log.d(TAG, "FOTO SINGOLA DA CANCELLARE nomeFoto: " + nomeFoto);
database.delete("foto", "nome_immagine=" + nomeFoto , null) ;
Log.d(TAG, "FOTO SINGOLA DA CANCELLATA" + nomeFoto);
databaseConnector.close(); // close the database
}
,但沒有。該risult是:
12-21 09:55:41.961: E/AndroidRuntime(11373): at java.lang.Thread.run(Thread.java:841)
12-21 09:55:41.961: E/AndroidRuntime(11373): Caused by: android.database.sqlite.SQLiteException: unrecognized token: "1419152123776.png" (code 1): , while compiling: DELETE FROM foto WHERE nome_immagine=1419152123776.png;
12-21 09:55:41.961: E/AndroidRuntime(11373): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
但照片的名字是正確的:
12-21 09:55:41.941: D/FotoDatabaseInterface(11373): FOTO SINGOLA DA CANCELLARE ID_Paziente: 2
12-21 09:55:41.941: D/FotoDatabaseInterface(11373): FOTO SINGOLA DA CANCELLARE nomeFoto: 1419152123776.png
任何想法?謝謝
它的工作原理!我想過這個,但是用一個變量名如何添加單引號?你的解決方案非常簡單。大! –