Хочу удалить данные одной строки в БД.Программа выдает следующую ошибку android.database.sqlite.SQLiteException: near "test1": syntax error (code 1): , while compiling: DELETE FROM items WHERE Name=test test1 test2 11 test3 and Qty=1
public class DataBaseHelper extends SQLiteOpenHelper {
private static String DB_NAME = "Cart1.DB";
private static final int DATABASE_VERSION=1;
private SQLiteDatabase myDataBase;
private final Context myContext;
public DataBaseHelper(Context context) {
super(context, DB_NAME, null, DATABASE_VERSION);
this.myContext = context;
}
@Override
public void onCreate(SQLiteDatabase db) {
final String CREATE_ITEMS_TABLE =
"CREATE TABLE " + DBDescription.Cart.TABLE_NAME + "(" +
DBDescription.Cart._ID + " integer primary key, " +
DBDescription.Cart.COLUMN_NAME + " TEXT, " +
DBDescription.Cart.COLUMN_QTY + " TEXT, " +
DBDescription.Cart.COLUMN_TOTAL + " TEXT, " +
DBDescription.Cart.COLUMN_IMG_PATH + " TEXT);";
db.execSQL(CREATE_ITEMS_TABLE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}
Удаление:
public void deleteTitle(String name,int total)
{
DataBaseHelper myDbHelper = new DataBaseHelper(context);
SQLiteDatabase db = myDbHelper.getWritableDatabase();
db.delete(DBDescription.Cart.TABLE_NAME,DBDescription.Cart.COLUMN_NAME + "=" + name + " and " + DBDescription.Cart.COLUMN_QTY + "=" + 1, null);
db.close();
myDbHelper.close();
}