concept DataManager in category android

This is an excerpt from Manning's book Android in Practice.
We’ll see how this is done when we discuss the DataManager interface and implementation object our application will use to wrap up all of our data operations methods in technique 35, but for now here’s an example of using our OpenHelper to obtain a SQLiteDatabase reference:
Because our DAOs are each unaware of any table other than their own, we’re also going to create a DataManager interface, an implementation class that will wrap the multiple DAOs and take care of the remaining duties from one place. Such duties will include storing data in multiple tables and dealing with transactions. Our application components will ultimately use this class to save and retrieve data. This technique, shown in the next listing, will keep all of the SQL and logic out of our application components and views.
Listing 7.18. The DataManager interface defines all possible operations
public interface DataManager { public Movie getMovie(long movieId); public List<Movie> getMovieHeaders(); public Movie findMovie(String name); public long saveMovie(Movie movie); public boolean deleteMovie(long movieId); public Category getCategory(long categoryId); public List<Category> getAllCategories(); public Category findCategory(String name); public long saveCategory(Category category); public void deleteCategory(Category category); }
The DataManagerImpl isn’t extending or building on any Android support, it’s our own invention that implements our DataManager interface
. Within it, we include a constant to define the current database version
and member variables that reference each of our DAOs
. Also, inside its constructor we instantiate the SQLiteOpenHelper class we built earlier
, and use it to connect to our database
.
. Within it, we include a constant to define the current database version
and member variables that reference each of our DAOs
. Also, inside its constructor we instantiate the SQLiteOpenHelper class we built earlier
, and use it to connect to our database
.