mardi 27 janvier 2015

Delete query not working sqlite

I am creating a app in which i have used sqlite db.I have successfully created the table and inserted data into it.But when i try to delete the data , the query doesn't seems to be working.


Code



public void deleteSubject(int Id) {
String query = "DELETE FROM " + TABLE_NAME + " WHERE " + DataBaseColumns.SUBJECT_ID + "=" + Id;
// String whereClause = DataBaseColumns.SUBJECT_ID + "=?";
database = openDb();
Cursor cursor = null;
try {
// result = database.delete(TABLE_NAME, whereClause, new String[Id]);
cursor = database.rawQuery(query, null);
} catch (SQLiteException e) {
Log.e("Error in delete Subjects", e.getMessage());
}
database = closeDb();
cursor.close();


}

Aucun commentaire:

Enregistrer un commentaire