Implementing DAO Pattern on Android project

android, dao, database, design-patterns

Solution

You can implement inserts,updates,deletes and all other operations in DBManager class or create a seperate class dao which does all the operations you want to do on the database...

    public class DAO {
private SQLiteDatabase database,customdb;
private DBManager dbHelper;



public DAO(Context context) {
    dbHelper = new DBManager(context);
}
public void open() throws SQLException {
    database = dbHelper.getWritableDatabase();

}
public void close() {
    dbHelper.close();
}
//insering,deleting and all other operations you want to perforem on the database
  }

Problem

I'm developing an Android 3.1 and above. I have the following packages: `es.viacognita.models` contain classes to store data retrieved with a web service. When I get all web service data, I need to insert it on database. To make it right, I've thought to use DAO pattern, but I don't know how to do it. If I use DAO pattern, may I need to use `es.viacognita.models` classes? I think that these classes are going to be DAO classes, isn't it? Where I have to implement inserts, updates, or deletes? on `DBManager` class?

Original source