dimanche 14 juin 2015

Inserting rows into table only once in Android Database

I want to only insert like 10 rows into a table at database creation. I do not want them added every time the app is open. Just once as a table with final values. How would I go about doing this? Thanks!

public void insertEvents(){
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put(COL_EVENT, "value1");
    values.put(COL_EVENT, "value2");
    values.put(COL_EVENT, "value3");
    values.put(COL_EVENT, "value4");

    db.insert(TABLE_EVENTS, null, values);
}

Aucun commentaire:

Enregistrer un commentaire