void checkDBVersion() { DBVersion dbNewVer = new DBVersion(); dbNewVer.m_strRhoVer = RhoRuby.getRhoDBVersion(); dbNewVer.m_strAppVer = RhoConf.getInstance().getString("app_db_version"); String strEncryptionInfo = getEncryptionInfo(); dbNewVer.m_bEncrypted = strEncryptionInfo != null && strEncryptionInfo.length() > 0; dbNewVer.m_bSqlite = true; DBVersion dbVer = new DBVersion(); dbVer.fromFile(m_strDbVerPath); if (dbVer.m_strRhoVer.length() == 0) { dbNewVer.toFile(m_strDbVerPath); return; } boolean bRhoReset = dbVer.isRhoVerChanged(dbNewVer); boolean bAppReset = dbVer.isAppVerChanged(dbNewVer); boolean bDbFormatChanged = dbVer.isDbFormatChanged(dbNewVer); if (!bDbFormatChanged && dbVer.m_bEncrypted) { //TODO: check encryption key //if (!com.rho.RhoCrypto.isKeyExist(strEncryptionInfo) ) // bDbFormatChanged = true; } if (bDbFormatChanged) { LOG.INFO("Reset Database( format changed ):" + m_strDBPath); } if (bRhoReset && !bAppReset && !bDbFormatChanged) { bRhoReset = !migrateDB(dbVer, dbNewVer); } if (bRhoReset || bAppReset || bDbFormatChanged) { if (!bDbFormatChanged) { IDBStorage db = null; try { db = RhoClassFactory.createDBStorage(); if (db.isDbFileExists(m_strDBPath)) { db.open(m_strDBPath, "", strEncryptionInfo); IDBResult res = db.executeSQL("SELECT * FROM client_info", null, false, false); if (!res.isEnd()) { m_strClientInfoInsert = createInsertStatement(res, "client_info"); m_dataClientInfo = res.getCurData(); } } }catch (Exception exc) { LOG.ERROR("Copy client_info table failed.", exc); }finally { if (db != null) { try { db.close(); } catch (Exception) { } } } } m_dbStorage.deleteAllFiles(m_strDBPath); if (this.m_strDbPartition.compareTo("user") == 0) //do it only once { String fName = makeBlobFolderName(); CRhoFile.deleteDirectory(fName); makeBlobFolderName(); //Create folder back } dbNewVer.toFile(m_strDbVerPath); if (RhoConf.getInstance().isExist("bulksync_state") && RhoConf.getInstance().getInt("bulksync_state") != 0) { RhoConf.getInstance().setInt("bulksync_state", 0, true); } } }