Ejemplo n.º 1
0
  public boolean storeOpponents(ArrayList<Opponent> opponents) {
    JSONArray ja = new JSONArray();

    try {
      for (Opponent o : opponents) {
        JSONObject jo = new JSONObject();
        jo.put(JSON_OPPONENT_PIN, o.getPlayer().getPin());
        jo.put(JSON_OPPONENT_WIN, (double) o.getResult());
        jo.put(JSON_OPPONENT_COLOR, o.getColor());
        jo.put(JSON_OPPONENT_HANDICAP, o.getHandicap());
        ja.put(jo);
      }
    } catch (JSONException e) {
      e.printStackTrace();
    }

    return mPrefs.edit().putString(OPPONENTS, ja.toString()).commit();
  }