Search code examples
androidkotlinandroid-volley

Volley response not return full data


I have an issue with getting a response from Volley. I have 3 data in tables, but volley only returns 2 data. This is what I got in the browser: pic And volley returns only index 0 and 1. Could anyone find out what's wrong? Here my Volley code

val stringRequest = StringRequest(Request.Method.GET, url,
  Response.Listener<String> {
    response ->
  Log.d("response", response)
  val jsonObj = JSONObject(response)
  val list = jsonObj.getJSONArray("list_pengaduan")
  if(list != null){
    for(i in 0 until list.length()){
      val adu = Pengaduan(
        list.getJSONObject(i).getInt("Id_pg"),
        list.getJSONObject(i).getString("Judul"),
        list.getJSONObject(i).getString("Tujuan"),
        list.getJSONObject(i).getString("Prodi"),
        list.getJSONObject(i).getString("Fakultas"),
        list.getJSONObject(i).getString("Kategori"),
        list.getJSONObject(i).getString("Image"),
        list.getJSONObject(i).getString("Post"),
        list.getJSONObject(i).getString("Slug"),
        list.getJSONObject(i).getString("Nim"),
        list.getJSONObject(i).getString("Modified"),
        list.getJSONObject(i).getString("Status")
      )
      pengaduan.add(adu)
}
adapter.notifyDataSetChanged()
}
},
Response.ErrorListener {
    error ->
  Log.d("error", error.toString())})

Volley.newRequestQueue(this).add(stringRequest)

Solution

  • Actually there is error in Volley's cache, so I need to use:

    Volley.newRequestQueue(this).cache.clear()

    before add a request