@Override
  protected void onStart() {
    final GameBoard boardView = (GameBoard) this.findViewById(R.id.gameBoard);
    SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE);

    this.level = prefs.getInt("level", 0);
    String mapJson = prefs.getString("map", null);

    if (mapJson == null) {
      waitForNext = true;
    } else {
      this.game.initGame(mapJson);
      String howdyPosition = prefs.getString("howdy", null);

      if (howdyPosition != null) {
        this.game.setHowdyPosition(howdyPosition);
      }

      Toast.makeText(this, this.level + "", Toast.LENGTH_SHORT).show();
    }

    String allDoneLevelsString = prefs.getString("doneLevels", null);

    if (allDoneLevelsString != null) {
      allDoneLevels = new ArrayList<String>(Arrays.asList(allDoneLevelsString.split(",")));
    }

    super.onStart();
  }
  @Override
  protected void onStop() {
    SharedPreferences prefs = getPreferences(Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = prefs.edit();

    editor.putInt("level", this.level);
    editor.putString("map", game.getLabyrinth().getJsonMap());
    editor.putString("howdy", game.getJsonHowdy());

    String allDoneLevelsString = "";

    for (String s : allDoneLevels) {
      allDoneLevelsString += s + ",";
    }

    if (allDoneLevelsString.length() > 0) {
      editor.putString(
          "doneLevels", allDoneLevelsString.substring(0, allDoneLevelsString.length() - 1));
    }

    editor.commit();

    super.onStop();
  }