Matt Williams wrote: > Confusion over the Application model. > Traditionally, I would have initialized my database as part of the > main applications startup process, but from the code examples I've > seen people seemed to be doing it all on a per activity basis, which > just seemed like repeating myself.
If by "initialized my database" you mean getting the SQLiteDatabase object, that's pretty cheap AFAIK in terms of RAM and CPU cycles. > I'm using a few threads that may attempt concurrent writes on the > database. There doesn't seem to be any documentation on whether > SQLDatabase its thread-safe or not, whereas I just assumed a > ContentProvider would be. I would not necessarily assume ContentProvider is single-threaded (there was some exchange between Ms. Hackborn and Mr. Nelissen on that topic on one of these lists recently, and I forget their collective conclusion on the issue). > If I was to instantiate the database in the > Application as a static singleton Ick. Statics can be dangerous in terms of memory leaks. > am I correct in assuming that I > would only need to set the method that queries the database to > synchronized? I usually just get an independent SQLiteDatabase object in any component (activity, service) that needs one and serialize any concurrent access to that object. SQLite should handle the rest, AFAIK. I'm not saying it's absolutely the best solution, but I haven't run into a problem yet. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android App Developer Training: http://commonsware.com/training.html --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---