Ok thanks, see below for my comments. On Sep 16, 6:15 pm, Kostya Vasilyev <[email protected]> wrote: > OnUpdate runs on the UI thread. I can see two ways to solve the concurrency > issue: > > - Use a service for updating the widget, consider using an IntentService for > database queries so they run on a worker thread - updating a widget can > supposedly be done from any thread, although I personally haven't done it.
How does this help exactly with the concurrency issue? Not trying to be snarky, I just truly don't understand. > > - Have your database update code prepare a "canned" version of data for the > widget, perhaps use SharedPreferences to store it. The widget's onUpdate > could then pick up this data very quickly, avoiding database queries > altogether. I might as well do #3 then :) > > - As a variation on the second way, update the widget preemptively from the > code that updates the data. You can invoke AppWidgetManager outside of > widget's onUpdate. I want to avoid this. The widget's data computation involves heavy database stuff, and a lot of things in my app can effect the final result. I would have to sprinkle a bunch of logic all over my app to handle all cases and even then, it would be pretty slow. So I thought I'd just use periodic update mechanism. Can I tell the AppWidgetManager that I am busy and come back to me in lets say 5 minutes? > > -- > Kostya Vasilyev --http://kmansoft.wordpress.com > > 17.09.2010 2:01 пользователь "Zsolt Vasvari" <[email protected]> написал: > > I am working on adding some app widgets to my app. I have a few > questions relating to this: > > Both the widgets and the app access the same SQLite database. What do > I need to be aware of as far as concurrency is concerned. Is this > even an issue? In other words, does the widget's onUpdate() method > run on the same thread as the app's main thread? > > Even if the above answer is "yes", I do have some long running > operations that's updating the database running in seperate threads. > If the onUpdate() is called while the long running operation is > executing, when I try to open the database even for reading, I would > fail. How would I handle this situation? > > Thanks for any pointers or links to past threads or blogs where > something like this had been discussed. > > -- > 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]<android-developers%[email protected]> > For more options, visit this group > athttp://groups.google.com/group/android-developers?hl=en -- 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

