+
+ private boolean updateAccountName(SQLiteDatabase db){
+ AccountManager ama = AccountManager.get(getContext());
+ boolean upgradedResult = true;
+ boolean upgraded = false;
+ try {
+ // get accounts ALREADY UPDATED from AccountManager
+ Account[] accounts = AccountManager.get(getContext()).getAccountsByType(MainApp.getAccountType());
+ String serverUrl, username, oldAccountName;
+ for (Account account : accounts) {
+ // build new account name
+ serverUrl = ama.getUserData(account, AccountUtils.Constants.KEY_OC_BASE_URL);
+ username = account.name.substring(0, account.name.lastIndexOf('@'));
+ oldAccountName = AccountUtils.buildAccountNameOld(Uri.parse(serverUrl), username);
+
+ // update values in database
+ db.beginTransaction();
+ try{
+ db.execSQL("UPDATE " + ProviderTableMeta.FILE_TABLE_NAME +
+ " SET " + ProviderTableMeta.FILE_ACCOUNT_OWNER + " ='" +
+ account.name + "' " +
+ " WHERE " + ProviderTableMeta.FILE_ACCOUNT_OWNER + " ='" +
+ oldAccountName + "' " );
+ upgraded = true;
+ db.setTransactionSuccessful();
+
+ Log_OC.i("SQL", "Updated account in database: old name == " + oldAccountName +
+ ", new name == " + account.name);
+
+ } catch (SQLException e){
+ upgraded = false;
+ } finally {
+ db.endTransaction();
+ }
+ upgradedResult = upgraded && upgradedResult;
+ }
+ } catch (Exception e) {
+ Log_OC.i("Exception", "Exception:" + e);
+ }
+
+ return upgradedResult;
+ }