Hello everyone, I have an application that uses a volley to get a given json data, so it works fine but the problem is the volley cache that does not reset until the application is completely closed, for example while the cell is not shut down or the application itself is closed by the task manager json data will not update in what way I can do so that in example every 30 minutes the data is updated.
My Code:
JsonArrayRequest arrayreq = new JsonArrayRequest(JsonURL, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
try {
JSONObject obj = response.getJSONObject(0);
String valor = obj.getString("valor");
String data = obj.getString("data");
results.setText("Vale R$: " + valor );
datav.setText("Última atualização: " + data);
} catch (JSONException e) {
e.printStackTrace();
}}},
new Response.ErrorListener() {
@Override
// Handles errors that occur due to Volley
public void onErrorResponse(VolleyError error) {
results.setText("Erro ao obter dados");
Log.e("Volley", "Error");
}
}
);
requestQueue.add(arrayreq);