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.
Please apply() the change when you make it. onDestroy() is not 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). Correct, but then onDestroy() is not necessarily called. Please 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? 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? It is equally as expensive as doing it in onDestroy(), because it is the same code. Using apply() does the save in a background thread. > Or should calls to commit be bundled and done as > infrequently as possible? Things that you do not apply() are not persisted. You need to persist them at some point and feel confident that "some point" will be reached. Persistence involves disk I/O. Doing a million disk I/O operations is more expensive than doing one. Hence, to some degree, "bundling" may be useful. Only you can draw the line at where you cannot afford to lose data. This is no different than choosing appropriate transaction bounds in database operation. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy Aqui estão alguns sites onde você pode perguntar ou responder dúvidas sobre desenvolvimento de aplicações para Android: http://www.andglobe.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