westmeadboy wrote: > The general situation is that I want multiple activities to have > access to a single database (which needs to be open all the time since > its the basis of just about every function/feature). > > Two approaches I can think of: > > 1. Quick and dirty workaround: In the example I gave, if > Activity2.onCreate() is called and the static has not been set, then > call finish(). I assume this will this just lead to Activity1 being > created? If so, that would be OK, for me.
Ick. > 2. Long-term good-practice approach: Handle opening/closing database > in the Application object. This seems like a logical place to put this > code. Initially, my app was just one activity and so I did all the app > configuration in that activity's onCreate() method. It felt wrong > then, and now I know why :) I've used the Application object, and I've used static singletons. Either way works. Particularly in your case, AFAICT, you just need something that can lazy-open the database if it's not already open. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android App Developer Training: http://commonsware.com/training -- 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

