title: boolean java.util.List.add(java.lang.Object)
body: <p>I am trying to get data from Shared Preferences and Inserting that data into List but it's getting me error. Although i have initialized the list but still it's getting this error</p>
  
  <blockquote>
    <p>java.lang.NullPointerException: Attempt to invoke interface method
    'boolean java.util.List.add(java.lang.Object)' on a null object
    reference</p>
  </blockquote>
  
  <pre><code>Information info = new Information(name, mobile, email, zone, type);
  List&lt;Information&gt; listItems = new ArrayList&lt;&gt;();
  SharedPrefManager sharedPrefManager = new SharedPrefManager(getActivity());
  listItems = sharedPrefManager.getDataFromSharedPreferences("info");
  listItems.add(info);
  sharedPrefManager.setDataToSharedPreferences("info", listItems);
  </code></pre>
  
  <p>Here is my SharedPrefManager getData Function</p>
  
  <pre><code>public List&lt;Information&gt; getDataFromSharedPreferences(String key) {
          Gson gson = new Gson();
          SharedPreferences sharedPref = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
          String jsonPreferences = sharedPref.getString(key, null);
  
          Type type = new TypeToken&lt;List&lt;Information&gt;&gt;() {
          }.getType();
  
          List&lt;Information&gt; contactList = gson.fromJson(jsonPreferences, type);
          return contactList;
  
      }
  </code></pre>