How to set the RequestQueue cache when creating RequestCache using Volley class?

254 views Asked by At

I'm creating a RequestQueue in a singleton class and the example provided by Google is creating it by a call of newRequestQueue of the Volley class that get as a parameter just the Context of the current application:

mRequestQueue = Volley.newRequestQueue(mCtx.getApplicationContext());

Previously I was not using a singleton class and I created a RequestQueue in the activity OnCreate with this code:

Cache cache = new DiskBasedCache(getCacheDir(), 1024 * 1024); // 1MB cap

// Set up the network to use HttpURLConnection as the HTTP client.
Network network = new BasicNetwork(new HurlStack());

// Instantiate the RequestQueue with the cache and network.
mRequestQueue = new RequestQueue(cache, network);

Because with this code I set network and cache I search for the Volley class for an appropriate newRequestQueue method but I noticed there is just two overloads of newRequestQueue, one with the HttpStack parameter that I can use to set the network, but there are not with a Cache parameter.

So the question is: there is a manner to create a RequestQueue with the Volley class costumizing its cache?

0

There are 0 answers