title: How do I display a response from a POST API when a user is offline?
body: <p>I am getting JSON response from server and I'm displaying it in Listview.
  It all works fine when the user has an active internet connection, But when user doesn't have any internet connection the app crashes.</p>
  
  <p>I want to implement a sync function here so that once the data is fetched by user it can even be seen if the user doesn't have an internet connection.</p>
  
  <p>I'm fetching the data using the following code:</p>
  
  <pre><code>        {
          Map&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
          params.put("param1", paramVal);
          JSONObject json = new JSONObject(params);
          String url = "https://dummy.com/getDetails";
  
  
          JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, url
                  , json, new Response.Listener&lt;JSONObject&gt;()
          {
              @Override
              public void onResponse(JSONObject response)
              {
                  try
                  {
  
                      JSONObject object = new JSONObject(String.valueOf(response));
                      String status = object.getString("status");
  
                      if (status.equals("200"))
                      {
                          JSONArray jsonArray = response.getJSONArray("arayname");
                          for (int i = 0; i &lt; jsonArray.length(); i++)
                          {
                             //Some Action Here
                          }
                          setupListview();
                      }
  
                  } catch (JSONException e) {
                      e.printStackTrace();
                  }
              }
          }, new Response.ErrorListener() {
              @Override
              public void onErrorResponse(VolleyError error) {
                  error.printStackTrace();
              }
          });
  
          mQueue.add(jsonObjectRequest);
      }
  </code></pre>