1

I want to fetch data from a json file to TextView but when my JSON url is an Address like "https://api.myjson.com/bins/16m4q8" works fine. but when url address is address of a file like "https://myaddress.com/file.json" it's show nothing.

private void loadData() {


 String url = "https://myaddress.com/file.json";


 JsonObjectRequest stringRequest = new JsonObjectRequest(Request.Method.GET, url, null,
  new Response.Listener < JSONObject > () {
   @Override
   public void onResponse(JSONObject response) {


    try {

     JSONArray array = response.getJSONArray("Asheghaneh");


     for (int i = 0; i < array.length(); i++) {


      JSONObject product = array.getJSONObject(i);

      String fasl1 = product.getString("fasl1");


      fasltext.setText(fasl1);

     }



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


  new Response.ErrorListener() {
   @Override
   public void onErrorResponse(VolleyError error) {

    Toast.makeText(ReadActivity.this, "ارووور", Toast.LENGTH_LONG).show();
   }

  });

 mqueue.add(stringRequest);
}
grrigore
  • 1,050
  • 1
  • 21
  • 39
AssassiN
  • 11
  • 1
  • 3

0 Answers0