Android Volley – 07 – Make a Json Array Request



This video demonstrates how to retrieve information from a remote database in the form of a JSON array using stolen and parser JSON objects.
Like my Facebook page:
Subscribe to My YouTube channel:

You may also like...

50 Responses

  1. excelente, el codigo donde esta porfavor?

  2. Can you make a video on how to incorporate this with search?

  3. Thank you sir, your video helped me a lot. I'm trying to make a messenger fro my web site. now I want to get auto update of thee messages. Can you please make a video for auto update data with json/volley?

  4. THANK YOU PRABEESH!!!

  5. Ans Ashraf says:

    Sir what if we want to send JsonArray to server

  6. if you had the problem of the empty screen you can fix it by puting all the code of getList (without return)in onCreate() method in Desplay activity and replacing contexe with Display.this and also putting these instructions (adapter=new RecyclerAdapter(list); recyclerView.setAdapter(adapter);)after the while loop in onResponse method… actualy the problem was that the get method returns the value of list before that it was ready(before the json object was parsed )u can check that with logs

    here is my code: i changed only names

    RecyclerView recyclerView;
    RecyclerView.Adapter adapter;
    RecyclerView.LayoutManager layoutManager;
    ArrayList<user> list=new ArrayList<>();
    Context context=Main2Activity.this;
    String url = "http://192.168.1.3/learn/hello.php&quot;;
    @Override
    protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main2);
    recyclerView=findViewById(R.id.recyclerView);
    layoutManager=new LinearLayoutManager(this);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setHasFixedSize(true);
    JsonArrayRequest jsonArrayRequest=new JsonArrayRequest(url, new Response.Listener<JSONArray>() {
    @Override
    public void onResponse(JSONArray response) {
    JSONObject jsonObject;user user;int i=0;
    while(i<response.length()){
    try {

    jsonObject=response.getJSONObject(i);
    user=new user(jsonObject.getString("name"),jsonObject.getString("email"));
    Log.d("__","affectation");
    list.add(i,user);
    i++;

    } catch (JSONException e) {
    e.printStackTrace();
    }

    }
    Log.d("__", "get"+String.valueOf(list.size()));

    adapter=new RecyclerAdapter(list);
    recyclerView.setAdapter(adapter);
    }
    }, new Response.ErrorListener() {
    @Override
    public void onErrorResponse(VolleyError error) {
    Toast.makeText(context,"error",Toast.LENGTH_LONG);
    error.printStackTrace();

    }
    });
    mySinglton.getmInstance(context).addToRequestQue(jsonArrayRequest);

    }
    }

  7. Coke Studio says:

    How long the code of length it make us too Difficult

  8. Coke Studio says:

    You are making it more difficult , why you didn't include it after Insert data then show on same activity , MIND Stuck Ufffff

  9. Lalji Yadav says:

    how we can parse two api at a time one api give response to another api key which use in another api parse function

  10. Hi, how I can to send parameters to json request?? Thanks!!

  11. how to send post request

  12. Sid Chopra says:

    He is good. But doesn't explain. Understanding logic behind the code is more important than the code itself.

  13. hello ! my recyclerview doesn't show ! i hade to press my searchview to see my recyclerview ! any help please..!

  14. Nice tutorial, Could you upload a video about how store token and used next request?

  15. Santosh350 says:

    I agree. The main problem with Prabeesh RK, in comparison with other YouTube programming experts, is that he only knows what he knows. Prabeesh K is terrible at debugging and figuring out other people's problems, when they ask "sir" about them in the comments. I recommend to check out android tut or Slidenerd. They are way smarter and better than Prabeesh RK.

  16. codernth nth says:

    bro do you have tutorial source code ?

  17. Kunal Singh says:

    its Pronounced Contact not Conduct -_-

  18. Sagar Ghare says:

    nice tutorial sir!!

  19. getting error "incompatible types: String cannot be converted to JSONArray"

  20. Thanks for Tutorials Sir….
    But first time i am getting data but next time when i reload the activity my listview is empty… not showing anything… and after sometime i reload again 2 or 3 time then it will show result….. Thank you Sir…Plz help…

  21. adil khan says:

    Sir ,,, help me about ip address no ip addres for mobile device ….. and not getting data from $_post why?

  22. sara vasseli says:

    Hi, thank you for tutorial really.
    I did every thing as tutorial, but in list, I just get the first item! I got no error. how could I debug this?

  23. John Louie says:

    good day to you. if you don't mind. can you make a Android multiple choice quiz app store in MySQL using volley. thank you

  24. The arrayList in the BackgroundTask returns empty, why is that happening ?

  25. Hamza Zahid says:

    Hy Sir,I did everything as you say but when i enter display list button my application get crash….please help me…
    Thanks…

  26. Sir problem in my code
    JSONObject jsonObject = response.getJSONObject((count));

    count not resolved please help me.

  27. Hello sir..its nice tutorial since im a beginner..But why is there is an issue on "cannot resolve symbol 'R' " in my coding

  28. News Today says:

    String Cannot be converted to JsonArray. Why ? help me,

  29. Joshua says:

    Hello PRABEESH R K!!

    I have followed all your steps, and it works in my XAMPP local server. But when I try this on a online database the .php file doesn't work. When I check the URL for the .php file it says to me : [{"Name":null,"Email":null}]
    Do you know why?

    Thank you. You are really helping me.

  30. SoftTech says:

    sir, in my case the arraylist size is zero while returning from getList() method but inside the OnResponse() method the arrayList size is not zero.How to fix this (while the code is similar to your's code)

  31. Amirul Arif says:

    sir, do you post the complete codes anywhere?

  32. Kamal Joshi says:

    Hello, can you tell me how can i display progress dialogue while making json array request.

  33. Hi.
    I did everything as you say. but in the "getList" method after onResponse(JSONArray response) my arraylist get empty. But I dont know why!!

  34. sir, can u make a video to parse json download to a listview and save it to the cache for offline storage and also implement searching

  35. Hello sir, thanks for this tutorial series 🙂 I am trying to make a SSL request using volley, which is giving me a SSl Exception. Can you please post some tutorial for SSL request using volley?

  36. hello my friend, i need to do exactly this, but showing only the user logged information, like username, age, adress and other things. for this i have a php file working fine, but i need send in json the username or password and i cant do this. please help me!
    Like i said, my php is fine, php take the email, find all user information and show in json format, but i cant show in a listview. by the way, i am using a fragment to do this…

  37. Hello Sir, my code returns empty arraylist when getList is called. when i continue debugging, in the second attempt it fills the arrayList. do you have any opinions?

  38. Hi Prabeesh I am using the same code to send the userID to the server database using getparams, but it is not sending the data, any help plz

  39. Joseph Joey says:

    Very nice video and also very easy to understand. How can one do json parsing inside a fragment? Should I make the json request in the ONCREATEVIEW() method or inside the ONCREATE() method? Thanks.

  40. sir how to send list view content like edit text and textview to server using volley..

  41. sir i get com.volley.timeoutError how to remove this error please make a lecture …. any one who try this above app in android studio got this error or not ????????

  42. Excellent tutorial. Thank you.

  43. Nice tutorial sir.
    but i am facing an issue in BackgroungTask class.
    getList method returning null arraylist, as arraList is added after method return null.
    How to fix this.

    i am using mongodb instead of Php and in log i can see the values are geting from jsonObject.

  44. nicknocknick says:

    My list is not showing after i click the button for the first time. so i have to go back then click again in order that the list is showed.
    Why is that?

  45. Hi, when I click button "Display List", only list of emails will display, no names…
    whats the problem ?
    where I might have made mistake ?
    please help…

  46. Sir, I had a problem, the data does not appear in the display json object, whether the mistake lies in ArrayList? thanks sir 🙂

  47. Pujit Gandhi says:

    Sir I went through entire tutorial …..list is not being displayed in recycler view…..stack trace showing arraylist.size….plz help