简体   繁体   中英

Android volley can't handle a 2mb json file

I'm hosting a json file in my vps and in my android app i'm trying to request it in order to save it in the user's device and so on. It's a 2.2 json mb file to be exact

Here's my code:

    public void sendJSONRequest(final String url) {
    JsonArrayRequest jsonArrayRequest  = new JsonArrayRequest(Request.Method.GET, url + "games.json", null, new Response.Listener<JSONArray>() {
        @Override
        public void onResponse(JSONArray response) {
            Toast.makeText(Main2Activity.this, "Cool", Toast.LENGTH_SHORT).show();
            // Log.d(TAG,"PLS: " + response);
            // mUpcomingGameReleasesList gets filled/appended with new data here
            // mUpcomingGameReleasesList.addAll(parseJSONResponse(response));
            // mUpcomingGamesAdapter.setData(mUpcomingGameReleasesList);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Toast.makeText(Main2Activity.this, error.getMessage(), Toast.LENGTH_SHORT).show();
        }
    });
    mRequestQueue.add(jsonArrayRequest);
}

Thank you

// try retry policy.

jsonArrayRequest.setRetryPolicy(new DefaultRetryPolicy(
                    30000,
                    DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
                    DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

        mRequestQueue.add(jsonArrayRequest);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM