I am working on an app, which has several modules.
I will have to access same database in many modules multiple times.
My question is Which place is the best way and best place to create the database and tables for it??
Like…
1. creating the required databases and tables at once while loading app or
2. Creating db and tables in respective modules when required??
resulting in extra lines of codes to check if db and table already
exists or not..
Which one is good option?? or is there other better way?
Any suggestions will be appreciated.
Thanks in advance 🙂
If you are using the db only within your app then I think the SQLiteOpenHelper is the best choice. It will create the table the first time when you use it. (It is suggested that you make your own helper a singleton class to avoid concurrent access issue).
If you are sharing the db among two or more apps then you should wrap the db behind a Content Provider.