title: Android sharedpreferences into arraylist
body: <p>I created a simple game. At the end the user's name and score is supposed to get into a highscore list. For this i would like to store these data in sharedpreferences. I saw a post and i am trying to apply it to my app but it force closes. I don't even know if this is the right thing i am doing. So i put these keypairs (player, score) into an arraylist. From there i can get the values out into a listview.
  This is just an example.</p>
  
  <pre><code>SharedPreferences.Editor scoreEditor = myScores.edit();
          scoreEditor.putString("PLAYER", "Thomas");
          scoreEditor.putString("SCORE", "5");
          scoreEditor.commit();
  
  
          final ArrayList&lt;HashMap&lt;String,String&gt;&gt; LIST = new ArrayList&lt;HashMap&lt;String,String&gt;&gt;();
          Map&lt;String, ?&gt; items = myScores.getAll();
  
          for(String s : items.keySet()){
              HashMap&lt;String,String&gt; hmap = new HashMap&lt;String,String&gt;();
              hmap.put("PLAYER", s);
              hmap.put("SCORE", items.get(s).toString());
  
              LIST.add(hmap);
          }
  
          Toast.makeText(Start.this, "LIST size: "+LIST.size(), Toast.LENGTH_LONG).show();
  </code></pre>
  
  <p>For me it would also be okay if i store these data like this:</p>
  
  <pre><code>scoreEditor.putString("DATA", "Thomas" + "-" + "5");
  </code></pre>
  
  <p>and put that into <code>ArrayList&lt;String&gt; LIST = new ArrayList&lt;String&gt;();</code></p>
  
  <p>but i don't know how to do it.</p>
  
  <p>Could you guys help me with this?</p>
  
  <p><strong>Edit:</strong> So i could go another way as Haphazard suggested. I put together this code, but i don't know if this is the way to do it. I haven't tested it yet, as sg is wrong with the sharedpreferences and i am still trying to figure it out.</p>
  
  <pre><code>SharedPreferences.Editor scoreEditor = myScores.edit();
  scoreEditor.putString("DATA", "Thomas" + "-" + "5");
  scoreEditor.commit();
  
  
  HashSet&lt;String&gt; hset=new HashSet&lt;String&gt;();
  hset.addAll((Collection&lt;? extends String&gt;) myScores.getAll());
  
  ArrayList&lt;String&gt; LIST = new ArrayList&lt;String&gt;(hset);
  </code></pre>