You can keep the data for that domain object in a singleton and then when you enter your details page there are two ways to go.
If for instance you had a list of Person class.
public class Person {
private String name;
private Image img;
...
}
Then you could have a PersonCache that was a singleton caching the data for the last Person selected in your list:
public class PersonCache {
private Person cachedPerson;
private static PersonCache instance;
private PersonCache(){
...
}
public PersonCache getInstance(){
if(instance == null){
instance = new PersonCache();
}
return instance;
}
public Person getCachedPerson(){
return cachedPerson;
}
public void setCachedPerson(Person p){
cachedPerson = p;
}
}
So in onCreate
when you finish fetching your JSON data you create a Person object and call setCachedPerson
.
If you know that the data in the details page won't have been updated:
In onCreate
in details page you check if the object that has been selected is the same as the one cached in your singleton (if the objects have unique ids in your database you can look at those to check if it's the same).
If you don't know whether there's new data:
You can use the If-Modified-Since technique when making your GET request in your AsyncTask.
Basically what you do is add a header parameter
key: If-Modified-Since
value: Sat, 29 Oct 1994 19:43:31 GMT
If the server has no new data it can respond with 304
and send no response body but if it has new data it will respond with 200
and send the data just like normal.
Implementing this would require some implementation on the server side as well.
Here's some more info on the technique:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html (section 14.25)