DAO SQLITE MVP Android

1

I'm creating a project and I'm using 3 layers .. presentation, logic, and data access! In my data class I need to access DAO (sqlite) but I need the context to use my DAO, but I can not use the context in this class because the context belongs to the presentation layer! how can I resolve this problem?

    
asked by anonymous 19.12.2017 / 19:49

2 answers

1

You can use the general context of the application getAplicationContext()

See if it works like this.

    
19.12.2017 / 20:08
0

There is a way to create a context I will write an example

public class DAO extends SQLiteOpenHelper {

   public DAO (Context context){
       super(context,DB_NAME,null,VERSAO);
   }
}

If it is in DBController

   public class DBController {

        private SQLiteDatabase db;
        private DAO dao;

        public DBController(Context context){
            dao = new DAO(context);
        }
}

That's how I got a context. Any questions are available.

    
19.03.2018 / 20:54