Thanks, Mark, for your help. Bottom line: I am not guaranteed that onDestroy() will be called before another invocation of onStartCommand(). It never occurred to me that was possible.
I'll apply() my changes every time the key is modified. Thanks. >>>>> "MM" == Mark Murphy <mmur...@commonsware.com> writes: MM> On Fri, Jan 18, 2013 at 11:42 AM, Jake Colman <col...@ppllc.com> wrote: >> The key is committed in the Service's onDestroy method. MM> Please apply() the change when you make it. onDestroy() is not MM> always called on components. >> The Service is started by my AppWidget every time the app widget >> needs to do some work. I do not explicitly stop the Service, >> relying on Android to stop it if/when needed (that is not bad >> practice as I understand it). MM> Correct, but then onDestroy() is not necessarily called. Please MM> apply() the change when you make it. >> In other words, would multiple calls to Application.onCreate cause >> the Service.onCreate to be called a second time without an >> intervening Service.onDestroy? MM> Yes, if onDestroy() was not called on the service. >> If this is the problem, is it expensive to persist a key as soon >> as it is changed? MM> It is equally as expensive as doing it in onDestroy(), because it MM> is the same code. Using apply() does the save in a background MM> thread. >> Or should calls to commit be bundled and done as infrequently as >> possible? MM> Things that you do not apply() are not persisted. You need to MM> persist them at some point and feel confident that "some point" MM> will be reached. MM> Persistence involves disk I/O. Doing a million disk I/O MM> operations is more expensive than doing one. Hence, to some MM> degree, "bundling" may be useful. Only you can draw the line at MM> where you cannot afford to lose data. This is no different than MM> choosing appropriate transaction bounds in database operation. MM> -- MM> Mark Murphy (a Commons Guy) MM> http://commonsware.com | http://github.com/commonsguy MM> http://commonsware.com/blog | http://twitter.com/commonsguy MM> Aqui estão alguns sites onde você pode perguntar ou responder dúvidas MM> sobre desenvolvimento de aplicações para Android: MM> http://www.andglobe.com MM> -- MM> You received this message because you are subscribed to the Google MM> Groups "Android Developers" group. MM> To post to this group, send email to android-developers@googlegroups.com MM> To unsubscribe from this group, send email to MM> android-developers+unsubscr...@googlegroups.com MM> For more options, visit this group at MM> http://groups.google.com/group/android-developers?hl=en -- Jake Colman -- Android Tinkerer -- 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