user3506595
user3506595

Reputation: 139

Insert default value while creating Table in android sqlite

I would like to know how to insert a default value to a table when it's created using Android Sqlite.

Upvotes: 2

Views: 1855

Answers (1)

Giru Bhai
Giru Bhai

Reputation: 14398

try this,it uses both text and integer type
replace MyTableName with yourtable

 @Override
            public void onCreate(SQLiteDatabase paramSQLiteDatabase) { // sqlite oncreate method
        paramSQLiteDatabase.execSQL("CREATE TABLE IF NOT EXISTS MyTableName(_id INTEGER DEFAULT 0,name TEXT DEFAULT 'ram');");
        }

Upvotes: 2

Related Questions