/** * Get the JSONArray of synchronized accounts * * @return synchronized accounts as a JSONArray */ public JSONArray getAccountsDetailsJSONArray() { JSONArray array = new JSONArray(); for (ServiceAccount sa : serviceAccountList) { array.put(sa.getAccountJSONDescription()); } return array; }
/** * Remove service account from this user * * @param accountDetails the account details as a JSONObject * @return true if the account has been deleted, false otherwise */ public boolean removeAccount(JSONObject accountDetails) { try { String saLogin = accountDetails.getString("login"); JSONObject saAccountSynchDetails = accountDetails.getJSONObject("details"); for (ServiceAccount saTemp : serviceAccountList) { if (saTemp.getLogin().contentEquals(saLogin) && saTemp .getAccountSynchDetails() .getString("id") .contentEquals(saAccountSynchDetails.getString("id"))) { return serviceAccountList.remove(saTemp); } } } catch (JSONException e) { e.printStackTrace(); } return false; }