title: Assigning value to a string inside onResponse method Volley
body: <p>Okey, I'm trying to get a Json response and return it as string using Volley. I have a method called <code>getWeatherData</code> which returns String which is the JsonObject comes from JSONObjectRequest response. In that method I'm creating a JsonObjectRequest called<code>request</code> with the url of my API which returns a JSON Object in response.<p> Now I want to take that JSON object inside the <code>onResponse</code> method but I couldn't figure out how to do it. I tried to creat a string in my<code>getWeatherData</code> function and the inside the <code>onResponse</code> method just assign that value to returning JSONObject but I get syntax error <em>'variable accessed from within inner class needs to be declared final'</em>.</p>
  
  <pre><code>public String getWeatherData(String place){
  
      String getJsonData;
      JsonObjectRequest request = new JsonObjectRequest(Utils.BASE_URL1 + place + Utils.BASE_URL2, new Response.Listener&lt;JSONObject&gt;() {
          @Override
          public void onResponse(JSONObject response) {
              getJsonData = response.toString();
          }
      }, new Response.ErrorListener() {
          @Override
          public void onErrorResponse(VolleyError error) {
              VolleyLog.d("json_retrieving-problem",error.getMessage());
          }
      });
  </code></pre>
  
  <p>All I want is to retrive the <code>JSONObject response</code> from the <code>onResponse</code> method and then return that value as string.</p>