/** Recreates the DB */ private void recreateTable(int currentVersion) { try { connetion.initTransaction(); if (currentVersion == 0) { currentVersion = createNewTables(); } if (currentVersion == 1) { currentVersion = updateToVersion2(); } if (currentVersion == 2) { currentVersion = updateToVersion3(); } if (currentVersion == 3) { currentVersion = updateToVersion4(); } if (currentVersion == 4) { currentVersion = updateToVersion5(); } if (currentVersion == 5) { currentVersion = updateToVersion6(); } if (currentVersion == 6) { currentVersion = updateToVersion7(); } if (currentVersion == 7) { currentVersion = updateToVersion8(); } connetion.commitTransaction(); } catch (SQLException e) { BotLogger.error(LOGTAG, e); } }
/** Private constructor (due to Singleton) */ private DatabaseManager() { connetion = new ConectionDB(); final int currentVersion = connetion.checkVersion(); BotLogger.info(LOGTAG, "Current db version: " + currentVersion); if (currentVersion < CreationStrings.version) { recreateTable(currentVersion); } }