長按 ListView 項目刪除 SQLite 數據後,ListView 不刷新。使用的是 SimpleCursorAdapter。
// 刪除數據庫記錄後
mDataBase.execSQL("delete from finance where _id=" + cc);
// 必須兩步:
cursor.requery(); // 1. 重新查詢獲取最新 Cursor
adapter.notifyDataSetChanged();// 2. 通知適配器數據變更
僅調用 notifyDataSetChanged() 無效,因 Cursor 仍指向舊數據集。