Volley org.json.JSONException: End of input at character 0 of when using fragment

  android, android-studio, android-volley, java, json

I am trying to get json data from my php server but whenever i try im getting "org.json.JSONException: End of input at character 0 of" also im using fragment for bottom menu

 private void getData() {
    // Initialize a new RequestQueue instance
    RequestQueue queue = Volley.newRequestQueue(this);
    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, dataurl+name, null, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            try {
                JSONArray array = response.getJSONArray("files");
                for (int i = 0; i < array.length(); i++) {
                    JSONObject songObject = array.getJSONObject(i);
                    SongList song = new AnimeList();
                    song.setURL(songObject.getString("url").toString());
                    song.setDate(songObject.getString("time").toString());
                    anlist.add(song);
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }

            recyclerView.setLayoutManager(new GridLayoutManager(MainActivity2.this, 3));
            recyclerView.setHasFixedSize(true);
            adapter = new WallpaperAdapter(MainActivity2.this, anlist);
            progressBar.setVisibility(View.GONE);
            recyclerView.setAdapter(adapter);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            Log.d("tag", "onErrorResponse: " + error.getMessage());
        }
    });
    // Add JsonObjectRequest to the RequestQueue
    jsonObjectRequest.setShouldCache(false);
    jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(DefaultRetryPolicy.DEFAULT_TIMEOUT_MS * 2,DefaultRetryPolicy.DEFAULT_MAX_RETRIES,DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
    queue.getCache().clear();
    queue.add(jsonObjectRequest);
}

Json
{files": [{"url": "http://192.168.0.19/asd/Wallpapers/778183.jpg","time": "April 09, 2021 21:34:02."}
When i don’t use fragment it works but when i use fragment i get err

Source: Android Questions

LEAVE A COMMENT