LA_ LA_ - 1 year ago 46
Java Question

How to add initial data to SQLite database?

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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download