title: Error trying to use GSON with own class
body: <p>I'm trying to use Google's GSON for the first time in my Android app. I want to use GSON with a class called <code>UserValues</code>, which keeps most of my ArrayList, booleans, Strings and other basic objects in one place. My goal is to save an instance of <code>UserValues</code> into <code>SharedPreferences</code>. I wrote:</p>
  
  <pre><code>Gson gson = new Gson();
          String userValuesJSON=gson.toJson(userValues);
          getSharedPreferences(myAppKey, MODE_PRIVATE).edit().putString("JSON", userValuesJSON).commit();
  </code></pre>
  
  <p>The error I get:</p>
  
  <pre><code>java.lang.SecurityException: Can't make method constructor accessible
              at java.lang.reflect.Constructor.setAccessible(Constructor.java:336)
              at com.google.gson.internal.ConstructorConstructor.newDefaultConstructor(ConstructorConstructor.java:97)
              at com.google.gson.internal.ConstructorConstructor.get(ConstructorConstructor.java:79)
              at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:71)
              at com.google.gson.Gson.getAdapter(Gson.java:356)
  </code></pre>
  
  <p>when I added GSON I added the following to <code>build.gradle</code>:</p>
  
  <pre><code>repositories {
      mavenCentral()
  }
  
  dependencies {   
      compile 'com.google.code.gson:gson:2.2.4'
  }
  </code></pre>
  
  <p>Any brainstorming greatly appreciated!</p>
  
  <p>EDIT: This is how the constructor looks like:</p>
  
  <pre><code>public class UserValues implements Serializable {
  
      private Integer period;
      private Float fee;
      private ArrayList&lt;Boolean&gt; theBooleans = new ArrayList&lt;&gt;();
      private ArrayList&lt;Integer&gt; theIntegers = new ArrayList&lt;&gt;();
      private static final ArrayList&lt;String&gt; theIntegerKeys = new ArrayList&lt;&gt;();
      private static final ArrayList&lt;String&gt; theBooleanKeys = new ArrayList&lt;&gt;();
      public static final String myAppKey = "Investor Playground";
      private static final ArrayList&lt;Integer&gt; theIntDefValues = new ArrayList&lt;&gt;();
      private ArrayList&lt;Float&gt; arrayList;
      private ArrayList&lt;ArrayList&lt;Integer&gt;&gt; theDates;
      private ArrayList&lt;Float&gt; strategyResult;
      private int theCurrentFragment;
  
      private int theCurrentGraph;
  
      Context context;
  
  
      public UserValues(Context context_) {
          context=context_;
      ...
  
      }
  </code></pre>