title: How to pass data around after parsing json Objects
body: <p>I am trying to create an app that will organize the COVID-19 information (#death, #inspection, #patiens...etc). I have found a website that is open-source and lets me use the JSON data. So I have parsed them; HOWEVER, I cannot pass the data around the mainActivity so I can create graphs and make calculations outside the method private <code>jsonParseRequest()</code>.</p>
  <p>This is the entire <code>jsonParseRequest</code> method so I can request <code>json</code> and parse it.</p>
  <p>What I have tried:</p>
  <ul>
  <li><p>I tried to make the method return the <code>json</code> data as string using <code>Integer.toString() (int ndeaths, int ninspections, int npatients)</code></p>
  </li>
  <li><p>Creating an <code>arrayList</code> making and add those data, but when I try to access it says error <code>IndexOutOfBounds</code>.</p>
  <pre><code>private void jsonParseRequest(){
      final TextView textView = (TextView) findViewById(R.id.textView);
      String url = &quot;https://www.stopcovid19.jp/data/covid19japan.json&quot;;
      RequestQueue queue = Volley.newRequestQueue(this);
  
      final JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener&lt;JSONObject&gt;() {
          @Override
          public void onResponse(JSONObject response) {
              try {
                  //Input the jsonObject to String called data
                  String data = response.toString();
                  //Create jsonObject and input the string data inside, so now the string data is converted to jsonObject?
  
                  JSONObject jsonObject = new JSONObject(data);
                  //Use json data to extract the data using the key such as &quot;ndeaths&quot;
                  int ndeaths = jsonObject.getInt(&quot;ndeaths&quot;);
                  int ninspections = jsonObject.getInt(&quot;ninspections&quot;);
                  int npatients = jsonObject.getInt(&quot;npatients&quot;);
                  String lastUpdate = jsonObject.getString(&quot;lastUpdate&quot;);
  
                  //the textView has to be converted to String ot be able to display!!
                  textView.setText(&quot;Last Update: &quot; + lastUpdate + &quot;\n&quot; + &quot;Number of deaths: &quot; + Integer.toString(ndeaths) + &quot;\n&quot; + &quot;Number of Inspection: &quot; + Integer.toString(ninspections) + &quot;\n&quot; + &quot;Number of Positives: &quot; + Integer.toString(npatients));
  
  
  
              } catch (JSONException e) {
                  e.printStackTrace();
              }
          }
      }, new Response.ErrorListener() {
          @Override
          public void onErrorResponse(VolleyError error) {
              error.printStackTrace();
          }
      });
      queue.add(jsonObjectRequest);
  }
  </code></pre>
  </li>
  </ul>