title: Gson deserializing nested objects with InstanceCreator
body: <p>I have a class named <code>PageItem</code>, which has a constructor that takes a <code>Context</code> as parameter:</p>
  
  <pre><code>PageItem(Context context)
  {
      super(context);
      this.context = context;
  }
  </code></pre>
  
  <p><code>PageItem</code> has these properties:</p>
  
  <pre><code>private int id; 
  private String Title; 
  private String Description; 
  public Newsprovider newsprovider; 
  public Topic topic;
  </code></pre>
  
  <p><code>Newsprovider</code> and <code>Topic</code> are other classes of my application and have the following constructors:</p>
  
  <pre><code>Newsprovider (Context context)
  {
      super(context);
      this.context = context;
  }
  
  Topic (Context context)
  {
      super(context);
      this.context = context;
  }
  </code></pre>
  
  <p><code>PageItem</code>, <code>Newsprovider</code> and <code>Topic</code> are subclasses of <code>SQLiteOpenHelper</code>.</p>
  
  <p>I want to deserialize <code>PageItem</code> array with Gson, so I wrote:</p>
  
  <pre><code>GsonBuilder gsonBuilder = new GsonBuilder();
  gsonBuilder.registerTypeAdapter(PageItem.class, new PageItemInstanceCreator(context));
  Gson gson = gsonBuilder.create();
  Pageitem pis[] = gson.fromJson(s, PageItem[].class);
  </code></pre>
  
  <p>with <code>PageItemInstanceCreator</code> defined as:</p>
  
  <pre><code>public class PageItemInstanceCreator implements InstanceCreator&lt;PageItem&gt;
      {
          private Context context;
  
          public PageItemInstanceCreator(Context context)
          {
              this.context = context;
          }
  
          @Override
          public PageItem createInstance(Type type)
          {
              PageItem pi = new PageItem(context);
              return pi; 
          }
  }
  </code></pre>
  
  <p>When debugging, a <code>PageItem</code> instance has correctly "MainActivity" as context while 
  but its <code>newsprovider</code> member variable has context = null.</p>
  
  <p>Gson created <code>PageItem</code> object using the right constructor but it created <code>Newsprovider</code> instance using the default parameterless constructor. How can I fix this?</p>