I have an android app that at oncreate(), load a json setting file from a server, json file that have google analytics id, admob code, etc. Then app run.
Here is my current function how looks like
private void makeJsonObjectRequest() {
JsonObjectRequest jsonObjReq = new JsonObjectRequest(Method.GET, url, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
JSONObject settings = response.getJSONObject("settings");
analyticid = settings.getString("google_anaytics");
admonbannerid = settings.getString("admob_banner");
admobinterstitialid = settings.getString("admob_interstitial");
} catch (JSONException e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(), Toast.LENGTH_LONG).show();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(TAG, "Error: " + error.getMessage());
Toast.makeText(getApplicationContext(), error.getMessage(), Toast.LENGTH_SHORT).show();
}
});
// Adding request to request queue
addToRequestQueue(jsonObjReq);
}
But to optimize that, I want to create a local setting file in user device, when I store these settings, and instead of calling json each time, I check first this file, to get settings, if empty, then I generate new file.
Any one know a solution for that or it's possible?
Much appreciate and thank you very much in advance