mercredi 4 mars 2015

SQLiteOpenHandler why do we need the Context variable?

I've started programing my first app in android, and noticed that in the constructor of SQLiteOpenHandler that is:



public SQLiteOpenHelper (Context context, String name, SQLiteDatabase.CursorFactory factory, int version)


I have a "Context" variable which role is unclear to me, because my intuition is to think that only one DB could exist with the same name NO mattar in what context I create it.

I've looked in the manual and it said:



Parameters: context to use to open or create the database



which did help me figure out the Context role ether. Therefore, I'd like to ask



  1. What is the role of the Context in the DB creation?

  2. Will different Data Base instances will be created for different Contexts but same DB name, factory and version?


Aucun commentaire:

Enregistrer un commentaire