在我添加1项后删除或更新然后我重新加载应用程序数据不会更改

时间:2018-06-06 10:26:08

标签: android

我添加,删除和更新数据但是在我添加1项后删除或更新然后我重新加载应用数据不会改变

数据库

public void deletePrefix(Prefix prefix) {
    Log.i(TAG, "MyDatabaseHelper.delete ... " + prefix.getOldPRe());

    SQLiteDatabase db = this.getWritableDatabase();
    db.delete(TABLE_PREFIX, COLUMN_PREFIX_ID + " = ?",
            new String[]{String.valueOf(prefix.getId())});
    db.close();
}

   public void updatePrefix(Prefix prefix) {
    Log.i(TAG, "MyDatabaseHelper.updatePrefix ... " + prefix.getOldPRe());

    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put(COLUMN_PREFIX_ID,prefix.getId());
    values.put(COLUMN_PREFIX_OLD, prefix.getOldPRe());
    values.put(COLUMN_PREFIX_NEW, prefix.getNewPre());

    db.update(TABLE_PREFIX, values, COLUMN_PREFIX_ID + " = ?",
            new String[]{String.valueOf(prefix.getId())});
    db.close();

}

胡亚蓉

db.addPrefix(prefix);
                prefixList.add(prefix);
                initializeRCV();
 db.updatePrefix(prefix);
                prefixList.remove(pos);
                prefixList.add(pos, prefix);
                initializeRCV();
db.deletePrefix(prefixList.get(position));
            prefixList.remove(position);
            initializeRCV();

somtime重新加载应用数据有所改变,但有时它不活跃

0 个答案:

没有答案