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. - 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. - 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. -- 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 at http://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

