I am using Volley
in application. I am sending data using REST
Api to server. This is the JSON POST
request to Server.
private void add() {
String NetworkStatus = biz.fyra.bookapp.utils.NetworkStatus.checkConnection(getContext());
if (NetworkStatus.equals("false")) {
alert.noInternetAlert(getActivity());
} else {
JSONObject info = new JSONObject();
try {
info.put("name", full_name);
info.put("phone", foodie_contact);
} catch (JSONException e) {
e.printStackTrace();
}
JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, ApiUrls.ADD, info, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
}) {
};
AppController.getInstance().addToRequestQueue(request);
}
}
If Internet is available I am able to POST data to server. But If Internet is not available I need to temporarily store this JSON object somewhere and when Internet is available I need to POST all JSON objects to server that were stored locally. How to achieve this ?