dimanche 21 décembre 2014

Delete an item in a sqlite database without id field

I try hard to delete a row in my table:



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


through line:



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

}


but nothing. the risult is:



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)


but the photo name is correct:



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


Any Idea? Thanks


Aucun commentaire:

Enregistrer un commentaire