数据库不更新

时间:2018-11-13 06:00:55

标签: android database model

我的数据库无法更新

这是我的updateMethod

  public long updateInfo(ModelInsertInfo modelInsertInfo) {
    SQLiteDatabase db = getWritableDatabase();
    ContentValues values = new ContentValues();
    values.put(KEY_ID,modelInsertInfo.getId());
    values.put(KEY_yearWater, modelInsertInfo.getYearWater());
    values.put(KEY_MonthWater, modelInsertInfo.getMonthWater());
    values.put(KEY_DayWater, modelInsertInfo.getDayWater());
    values.put(KEY_HourWater, modelInsertInfo.getHourWater());
    values.put(KEY_MinWater, modelInsertInfo.getMinWater());
    return db.update(TABLE_Insert_Info, values, "" + KEY_ID + "= " + modelInsertInfo.getId() + "", null);
}

这是活动代码

ModelInsertInfo modelInsertInfo = new ModelInsertInfo();
                    ActionInsertInfo actionInsertInfo = new ActionInsertInfo(getApplicationContext());

                    modelInsertInfo.setYearWater(yearFC);
                    modelInsertInfo.setMonthWater(monthFC);
                    modelInsertInfo.setDayWater(day1);
                    modelInsertInfo.setHourWater(hour);
                    modelInsertInfo.setMinWater(min);

                    long check = actionInsertInfo.updateInfo(modelInsertInfo);

                    if (check > 0) {
                        Snackbar.make(null, ":)", Snackbar.LENGTH_SHORT).show();
                    }else 
                    {
                        Toast.makeText(ActivityDetails.this, ":(((", Toast.LENGTH_SHORT).show();
                    }

当选择按钮返回-1并且我使用外部数据库时 谢谢帮助我:)

0 个答案:

没有答案