title: Save and Retrieving ArrayList to SharedPreferences
body: <p>This is my Saving Program Code this will save the score, date and the player name to the leaderboard:</p>
  
  <pre><code>mLeaderboardlist = new ArrayList&lt;&gt;();
     Leaderboardmodel s = new Leaderboardmodel();
     s.setDate("07/24/17");
     s.setName(player.getText().toString());
                      s.setScore(Integer.parseInt(String.valueOf(yourScore.getText())));
              Tab1Normal.mLeaderboardlist.add(s);
              SharedPreferences appSharedPrefs = PreferenceManager
                              .getDefaultSharedPreferences(getApplicationContext());
                      SharedPreferences.Editor prefsEditor = appSharedPrefs.edit();
                      Gson gson = new Gson();
                      String json = gson.toJson(s);
                      prefsEditor.putString("MyObject", json);
                      prefsEditor.apply();
                      prefsEditor.commit();
  </code></pre>
  
  <p>And this is my retrieving program code of dealing also in sharedpreference:</p>
  
  <pre><code> SharedPreferences appSharedPrefs = PreferenceManager
                  .getDefaultSharedPreferences(this.getActivity().getApplicationContext());
          Gson gson = new Gson();
          String json = appSharedPrefs.getString("MyObject", "");
          Type type = new TypeToken&lt;ArrayList&lt;Leaderboardmodel&gt;&gt;(){}.getType();
          ArrayList&lt;Leaderboardmodel&gt; leaderboard= gson.fromJson(json, type);
              Collections.sort(leaderboard);
              adapter = new ListLeaderBoardAdapter(getActivity(), leaderboard);
              lvLeaderboardlist.setAdapter(adapter);
  </code></pre>
  
  <p>The save saving part work fines but the retrieving part display an error and makes the application crash, the error display :</p>
  
  <blockquote>
    <p>com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 path $</p>
  </blockquote>