我正在尝试根据传入参数更新数据库,但它没有更新。 我使用以下代码:
public static void markFavoriteStation(String station, boolean favorite){
Log.d(AppConstants.TAG,"StationListDBIfc: +markFavoriteStation");
String Query = null;
mDb = bartDb.getWritableDatabase();
Query = "update stationlistTable set favorite ='1' where namewithabbr = '+station'";
mDb.rawQuery(Query, null);
Log.d(AppConstants.TAG,"StationListDBIfc: -markFavoriteStation");
}
答案 0 :(得分:1)
我认为你的字符串定义可能不正确。你应该在将“station”变量连接到它之前结束字符串,如下所示:
Query = "update stationlistTable set favorite ='1' where namewithabbr = '" + station + "'";
答案 1 :(得分:0)
我看不出任何错误。我猜SQL查询有错误或namewithabbr列不包含您的期望。你应该在sqlite3 app中测试它。