Reputation: 893
is it possible to initialize the contentprovider in the application?
because i need to create a database for every user/server combination and I'm creating the database with the login information in the oncreate method of the the contentprovider!
Upvotes: 3
Views: 1647
Reputation: 193
Based on what it sounds like you are trying to do, you may consider contextualizing your ContentProvider's database access (this may be another way of describing what @Gary B. was getting at):
When you initialize the content provider, create a database within which you will store the list of user/server combinations. Then, when a user logs into the application, create the corresponding database and update the master list for the ContentProvider.
In the ContentProvider's public operations, determine which user/server combination is active (or being requested) and then look up the appropriate database in the master database you created on installation. You can then read the user/server specific information and return this to the caller.
Alternatively, you could likely implement this all within one database, but I don't understand enough about your requirements to recommend a specific approach...
Upvotes: 2
Reputation: 12410
An SQLiteOpenHelper is usually the place to do database creation. More specifically the onCreate(SQLiteDatabase)
method. It will create the database when the app is installed.
Upvotes: 0