title: Save ArrayList in shared preferences
body: <p>i am searching for hours to find out why saving boolean list in shared preferences is not working.</p>
  
  <p>The methods are not saving or loading something... the loadmethod always returns the alternative values: so list_size as 0 and the booleans as false.</p>
  
  <p>First of all i create the list in my MainActivity and call the save Method:</p>
  
  <pre><code>SaveLoadTraining sLoad = new SaveLoadTraining();
      ArrayList&lt;Boolean&gt; listBoolTrain = new ArrayList&lt;Boolean&gt;();
      listBoolTrain.add(true);
      listBoolTrain.add(true);
      sLoad.saveArray(listBoolTrain);
  </code></pre>
  
  <p>The subclass SaveLoadTraining looks like this:</p>
  
  <pre><code>    package de.sebspr.app08.halle;
  
  import java.util.ArrayList;
  
  import android.content.Context;
  import android.content.SharedPreferences;
  import de.sebspr.app08.MainActivity;
  
  public class SaveLoadTraining {
  
      private Context context;
      public static final String PREFS_NAME = "ListFile";
      private ArrayList&lt;Boolean&gt; list;
  
      public SaveLoadTraining(){
          this.context = MainActivity.getMContext();
      }
  
      public void saveArray(ArrayList&lt;Boolean&gt; list){
  
          this.list = list;
  
          SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0);
          SharedPreferences.Editor editor = settings.edit();
  
          int size = list.size();
          editor.putInt("list_size", size);
  
          for (int i = 0; i &lt; size; i++) {
              editor.remove("list_"+i);
          }
          for (int i = 0; i &lt; size; i++) {
              editor.putBoolean("list_"+i, list.get(i));
          }       
          editor.commit();
      }
  
      public ArrayList&lt;Boolean&gt; loadArray(){
  
          SharedPreferences file = context.getSharedPreferences(PREFS_NAME, 0);
          list = new ArrayList&lt;Boolean&gt;();
          int size = file.getInt("list_size", 0);
  
          for(int i = 0; i&lt;size;i++){
              boolean bool = file.getBoolean("list_"+i, false);
              list.add(bool);
          }
          return list;
      }
  }
  </code></pre>
  
  <p>I can not figure out what is going wrong...</p>
  
  <p>Perhaps i handle the context on a wrong way?
  I just call this method to get the context of the MainActivity:</p>
  
  <pre><code>...
  mContext = this;
  ...
      public static Context getMContext(){
          return mContext;
      }
  </code></pre>