How to add initial data to SQLite database?

后端 未结 6 1643
逝去的感伤
逝去的感伤 2021-02-14 07:04

I need to add initial values to SQLite database, once application is started first time. How should I do it?

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-14 07:33

    In DBAdapter.java class file you can do that.


        @Override
        public void onCreate(SQLiteDatabase db) {
            db.execSQL(CREATE_TABLE_1);
            db.execSQL(CREATE_TABLE_2);
            db.execSQL(CREATE_TABLE_3);
            db.execSQL("insert into " + DATABASE_TABLE3 + "(" + KEY_ROWID + ","
                    + KEY_DEF + ") values(1,'')");
        }
    

    Like this type.

提交回复
热议问题