lundi 22 février 2016

Android SQLite, update specific field from specific row

I am trying to update a specific column in my record within SQLite - the object has various attributes, but I just want to update a single field within that row. Here are my codes:

public boolean updateFavorite(String email, int isFavorite){
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues args = new ContentValues();
    args.put(EMAIL, email);
    args.put(IS_FAV, isFavorite);

    int i = db.update(TABLE_FAVORITES, args, EMAIL + "=" + email, null);

    return i > 0;
}

I am using the email for my where clause, i.e update record from favorites, set isFavorite to (given value) where email is (passed in value).

There is a problem with my query, which was caught by logcat, as shown below

android.database.sqlite.SQLiteException: near "@sjisis": syntax error (code 1): , while compiling: UPDATE Favorites SET email=?,isFavorite=? WHERE email=sjkshs@sjisis.com

Can anyone help me identify what is wrong with my codes to produce this error?

P.S my FavoriteObject class has other attributes other than just email and isFavorite, but in this case I am not trying to update them at all

Aucun commentaire:

Enregistrer un commentaire