0

I have a database as follows. I want to write default values to this table when the table is created

db.execSQL("CREATE TABLE "+ DATABASE_TABLE + "(" +
    KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
    KEY_CTYPE + " TEXT NOT NULL," +
    KEY_SNAME + " TEXT NOT NULL," +
    KEY_SNUMB + " TEXT NOT NULL," +
    KEY_USRN  + " TEXT NOT NULL," +
    KEY_PASS  + " TEXT NOT NULL," +
    KEY_EMPTY + " INTEGER);"
);

how should i do it?

1

1 Answer 1

1

in the oncreate after creating the Table add all the entries using a for loop

After

    db.execSQL("CREATE TABLE "+ DATABASE_TABLE + "(" +
            KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
            + KEY_CTYPE + " TEXT NOT NULL,"
            +  KEY_SNAME + " TEXT NOT NULL,"
            +  KEY_SNUMB + " TEXT NOT NULL,"
            +  KEY_USRN + " TEXT NOT NULL,"
            +  KEY_PASS + " TEXT NOT NULL,"
            +  KEY_EMPTY + " INTEGER);"
    );

call your createEntry method in a loop 8 times and add the default values using ContentValues

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.