title: Google Volley Singleton pattern Request Queue Lints
body: <p>I have been trying to implement <code>Volley</code> in my project. I am using google developers <a href="https://developer.android.com/training/volley/index.html" rel="nofollow noreferrer">guide</a> for understanding the concepts.</p>
  <p>In the second lesson, setting up <code>RequestQueue</code> as a singleton(Recommended practice) is taught. The following is a code snippet from that <a href="https://developer.android.com/training/volley/requestqueue.html#singleton" rel="nofollow noreferrer">lesson</a>.</p>
  <pre><code>public class MySingleton {
      private static MySingleton mInstance;
      private RequestQueue mRequestQueue;
      private ImageLoader mImageLoader;
      private static Context mCtx;
  
      private MySingleton(Context context) {
          mCtx = context;
          mRequestQueue = getRequestQueue();
  </code></pre>
  <p>Now coming to my question, when I followed this code I'm getting lints (in Android Studio 2.2) as follows.</p>
  <blockquote>
  <p>Do not place Android context classes in static fields (static
  reference to ApiRequestQueue which has field context pointing to
  Context); this is a memory leak (and also breaks Instant Run)</p>
  </blockquote>
  <p>For the lines 2 and 5 in the above snippet.</p>
  <p>What should I do? Should I suppress them or is there a way around?</p>
  <p>Thanks.</p>