By Default load some data into our database sqlite
I want to insert some tables by default to our sqllite
db.
I want to display different items according to different categories. In the 开发者_如何学Pythonapplication, a user can also add items and new categories, for that purpose I want to add some data to db by default. How can we add data to sqlite
by default. Please give me some suggestions.
Thanks in advance
You can pre-package the database by creating the database with a SQLite database editor and then put the pre-made database in your assets folder which you can then access from your app.
I suppose you use the SQLiteOpenHelper
, as in the Notepad tutorial.
SQLiteOpenHelper
's onCreate()
method is called if the database is not yet created. This is the place where initial population of the tables should happen.
精彩评论