I may be getting way off topic and you might want to take this off line.
the last two responses seem to contradict themselves.
“but the application has one major downside: you can only have one”
As far as Singletons in response to this questions So then are you saying that a multi-table application should have a singleton class for each of the tables? “The typical pattern is not to have a separate interface (and singleton) for each table, but to have one central interface for each store of data. The store could represent a web service, a file, but more often than not it’s a SQLite database.”
The second response seems to indicate that a application object would be just fine.
I really learned a lot in your book by the way that I’m incorporating in my capstone project, i.e. loaders and fragments. The trouble I’m having is that I was using an application class to…
OK here’s my project. It’s a construction management project which has a database with three tables: a project table, a visit table and a photo table. You have a project. You go on a visit to the project and you take pictures during the visit.
You create a project and it gets entered in the project table. You go on a sight visit and it gets entered in the visit table. You take pictures during the site visit and they get entered in the photos table. I was using the application class to keep track of where I was. If I selected a project, it stored the projectId. If I went on a visit it stored the projectId and the visitId. If I took a picture during the visit it stored the projectId, visitId and photoId. As I backed out from photo to visit to project it would store less and less. I was using the application class to store these ids.
I had an abstract DB adapter that created the database and tables and opened and closed them. Then each table had a DB adapter that handled the CRUD for each table.
So what am I getting at? I guess I’m asking
did the two responses conflict because I’ve kind of adopted your philosophy but pulled the DB access out of the Singleton and put it back in the activity/fragment
which way is more efficient, the way I was doing it with the db adapters or the way you’re doing in it one db helper class if you have multiple tables
Or maybe I’m not getting that your Singleton is my db adapter class.