title: Android:how to store and retrieve Hashmap data in sharedpreferences?
body: <p>I want to store some data like key and value pair in internal storage.
  so i am using HashMap to store key,value pair .but i don'get sufficient solution to store and retrieve this HashMap into sharedpreferences. 
  Please give me some solution.</p>
  
  <p>i am put my code below:</p>
  
  <pre><code>HashMap&lt;String, String&gt; MapListMesasges = new HashMap&lt;String, String&gt;();
  MapListMesasges.put(FromName, message.getBody());
  preferences = mActivity.getSharedPreferences(
                                  SharePreference_messages_history_name,
                                  Context.MODE_PRIVATE);
                          SharedPreferences.Editor editor = preferences.edit();
                          for (Entry&lt;String, String&gt; entry : MapListMesasges
                                  .entrySet()) {
                              editor.putString(entry.getKey(), entry.getValue());
                          }
                          editor.commit();
  </code></pre>
  
  <p>and retrieve data from Sharedprefernces:</p>
  
  <pre><code>preferences = mActivity.getSharedPreferences(
                  SharePreference_messages_history_name, Context.MODE_PRIVATE);
          for (Entry&lt;String, ?&gt; entry : preferences.getAll().entrySet()) {
              MapListMesasges.put(entry.getKey(), entry.getValue().toString());
          }
  </code></pre>
  
  <p>i will also store hashmap in adapter and  set into listview.
  My main purpose is to store and retrieve data into sharedprefernces and also show data into listview.</p>
  
  <p>Thanks in advance.</p>