Implementing a DAO Template in an Android Project

I am developing Android 3.1 and higher.

I have the following packages:

enter image description here

es.viacognita.modelscontain classes for storing data retrieved using the web service. When I get all the web service data, I need to insert it into the database.

So that everything was correct, I decided to use the DAO template, but I do not know how to do it.

If I use the DAO pattern, can I use classes es.viacognita.models? I think these classes will be DAO classes, right?

Where do I need to implement inserts, updates, or delete? in DBManagerclass?

+5
source share
2 answers

, , DBManager dao , , ...

    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
  }
+5

DBManager. - DAO (DAL). , - .

+2

All Articles