On Sun, Aug 26, 2012 at 4:39 AM, Gianluca Cacace <[email protected]> wrote: > I've a service which consume some tasks queued by an activity (this service > uploads each queued video to a http server). I want to show the upload > status in an activity (with a listview, like Youtube). What can I do to keep > in sync the listview with the service progress? > > I don't know if it's a best practice to store data to a SQLite db, then, > when I open the activity containing the listview, I'll register a broadcast > receiver which listen service changes notifications.
You don't need to use a database just for synchronization. Hold your data model someplace central to the activity and the service (e.g., static data member, *carefully*). Then, local broadcasts via LocalBroadcastManager, or Otto's message bus, could be used to trigger updates. Or, hold your data model in memory wrapped by a ContentProvider (with support for a limited subset of provider operations), and use ContentObservers to propagate updates. If you need a database for other reasons (e.g., these tasks should be durable in case your process is terminated), then also using that for synchronization may be reasonable, whether via local broadcasts or ContentObserver or whatever. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Android Training in NYC: http://marakana.com/training/android/ -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

