Reputation: 139
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
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