AppWidgetProvider objects are transient, can be destroyed very quickly after they're needed (for onUpdate, etc.). Because of this, storing data there is pretty much useless.

Using the service is better, but services can be stopped (by the system or by the user).

I recommend making a static somewhere, which by definition lives as long as the process. You can wrap it in a nice class, such as:

class DataCache {

public static List<DataItem> getMostRecentData() {
....
}

private static List<DataItem> ..... ;
}

The process can be killed too, and next time it's launched, any statics will initially be empty. Make sure your code can handle this: doesn't crash and initiates getting the data from somewhere.

You might want to have a persistent data cache as well (using a SQL database or any other storage mechanism).

-- Kostya

05.05.2011 16:40, Niall пишет:
Just another quick question. I want to keep track of update-to-update changes. So I have a List<List<int>> variable containting my data (which I've parsed from the net). At the end of updating I copy this value to another variable. I need to keep track of these variables. Does it make more sense to store them in the appwidget class or the service class that I'll be using? I think it makes more sense for the former, but I'm still sorta trying to get my head around the thing so I may be wrong.


--
Kostya Vasilyev -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to