public static boolean deleteTable(Databases db) { try { SQLiteDatabase sql = db.getWritableDatabase(); String query = "DELETE from " + TABLE_NAME; LOG.log("Query:", "Query:" + query); sql.execSQL(query); sql.close(); return true; } catch (Exception e) { return false; } }
public static boolean inseartOperation(Databases db, FoodItem item) { SQLiteDatabase sql = db.getWritableDatabase(); String query = ""; query = "insert into " + TABLE_NAME + " (" + FOOD_ID + "," + NAME + "," + RATE + "," + DESCRIPTION + "," + IMAGE_URL + ") values (" + "" + item.id + "" + "," + "'" + item.name + "'" + "," + "" + item.rate + "" + "," + "'" + item.description + "'" + "," + "'" + item.imageUrl + "'" + ");"; LOG.log("Query:", "Query:" + query); sql.execSQL(query); return true; }
public static boolean updateOperation(Databases db, FoodItem item) { SQLiteDatabase sql = db.getWritableDatabase(); String query = ""; query = "update " + TABLE_NAME + " SET " + FOOD_ID + " = " + item.id + " , " + NAME + " = '" + item.name + "' , " + RATE + " = " + item.rate + " , " + DESCRIPTION + " = '" + item.description + "' , " + IMAGE_URL + " = '" + item.imageUrl + "' " + " WHERE " + FOOD_ID + " = " + item.id + ""; LOG.log("Query:", "Query:" + query); sql.execSQL(query); sql.close(); return true; }