I\'m using Volley to POST some data stored in a local database to a server. The problem is when I have a big number of entries (for example 500) I get this error:
The problem is I was creating a new RequestQueue for every request. That's the reason I suspect it was throwing the OutOfMemory Exception. The solution is simple:
instead of RequestQueue requestQueue = Volley.newRequestQueue(context);
declare the RequestQueue outside the method and add a new RequestQueue only if the previous one is null.
private RequestQueue requestQueue;
public void uploadData(String s) {
if (requestQueue == null) {
requestQueue = Volley.newRequestQueue(context);
Build.logError("Setting a new request queue");
} more request stuff....
}