Ok, so I just learnt about the SQLite API in android. All the tutorials talk about creating a helper class which extends the SQLIteOpenHelper. There is a constructor which as I understood creates the database and there is a onCreate callback which is used to create all the tables the first time the database is created. Till here, OK.
My doubts are: Suppose, I create a database from one activity/class. My helper class is called DatabaseHelper. So, if I want to access the database from that creator class itself, then no problem. I just use the instance of DatabaseHelper which I would have created and then use that to access and work on the database.
But, how will I work on the same database from some other activity which needs to access the database. My doubt here is that since in this class I would have to create a new DatabaseHelper object, won't that go through the super constructor call and the onCreate callback again. And won't that be a problem? What effects will it have on the database.
I am basically not able to understand how can I create a database once in my app and then just it anywhere from the app.
Aucun commentaire:
Enregistrer un commentaire