D
Deleted User
Guest
Hi,
Suppose I have a list view populated with data from a web service. I certainly don't want to take time hitting the WS if I could pull locally by saving the instance state or by some other means (meaning when the device is rotated or whatever causes the Activity to be re-created).
My question here is: What is the best way to do this?
I suppose I could work up a function to save each list item to SaveInstanceState by looping through each row and creating a dynamic name (ie: "listItem1", "listItem2", etc) and then read until listItemX doesn't exist (right?). Or would it be more appropriate to just write the values to a local db and pull from them (and would I highjack the onSaveInstanceState method to do this)?
Since I don't want to call the WS each time the Activity is created if the user likely won't get any new data, I was thinking of making a db table that stores the results from a previous WS. If that table is empty or the results are more than 5 minutes old, I will call the WS. I would also provide a refresh button for the user. How does this sound?
Thanks for your help
Suppose I have a list view populated with data from a web service. I certainly don't want to take time hitting the WS if I could pull locally by saving the instance state or by some other means (meaning when the device is rotated or whatever causes the Activity to be re-created).
My question here is: What is the best way to do this?
I suppose I could work up a function to save each list item to SaveInstanceState by looping through each row and creating a dynamic name (ie: "listItem1", "listItem2", etc) and then read until listItemX doesn't exist (right?). Or would it be more appropriate to just write the values to a local db and pull from them (and would I highjack the onSaveInstanceState method to do this)?
Since I don't want to call the WS each time the Activity is created if the user likely won't get any new data, I was thinking of making a db table that stores the results from a previous WS. If that table is empty or the results are more than 5 minutes old, I will call the WS. I would also provide a refresh button for the user. How does this sound?
Thanks for your help