@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; ClientDao other = (ClientDao) obj; if (db == null) { if (other.db != null) return false; } else if (!db.equals(other.db)) return false; return true; }
@SuppressWarnings("unused") private void updateTable(SQLiteDatabase db) { try { db.beginTransaction(); logger.d("moguimdb onUpgrade DB table start"); // rename the table String alterMessageTableSql = getAlterTableSql(DBHelper.TABLE_MESSAGES); db.execSQL(alterMessageTableSql); logger.d("moguimdb onUpgrade DB alter table"); // creat table db.execSQL(CREATE_MESSAGES); // TODO 升级时改成新表名 logger.d("moguimdb onUpgrade DB create new table"); // load data logger.d("moguimdb onUpgrade DB load data"); String selectColumns = getColumnNames(db, DBHelper.TABLE_MESSAGES + TEMP_SUFFIX); // 记得用旧表名哦 String updateMessagesSql = "insert into " + DBHelper.TABLE_MESSAGES + " (" + selectColumns + ") " + "select " + selectColumns + "" + " " + " from " + DBHelper.TABLE_MESSAGES + TEMP_SUFFIX; logger.d("moguimdb onUpgrade DB updateMessagesSql : " + updateMessagesSql); db.equals(updateMessagesSql); // drop the oldtable logger.d("moguimdb onUpgrade DB drop old table"); String dropMessageTableSql = getDropTableSql(DBHelper.TABLE_MESSAGES + TEMP_SUFFIX); db.execSQL(dropMessageTableSql); logger.d("moguimdb onUpgrade DB table end"); db.setTransactionSuccessful(); } catch (Exception e) { logger.d("moguimdb onUpgrade DB error with reason: " + e.toString()); } finally { db.endTransaction(); } }