android - setting a default value to a column in SQLite -


i having sqlite table , wish set default value time being. how can that?

below databasehelper class code:

import android.content.context; import android.database.sqlite.sqlitedatabase; import android.database.sqlite.sqliteopenhelper;  public class databasehelper extends sqliteopenhelper {      private static final string database_name="ifall.db";     public static final string time="time";     //public static final string status="status";     //public static final string mines="loadmines";     //public static final string opentile="opentile";      public databasehelper(context context)     {         super(context,database_name,null,1);     }     @override     public void oncreate(sqlitedatabase arg0) {         // todo auto-generated method stub         //create table minesweeper(_id integer primary key autoincrement,userid text         arg0.execsql("create table finalp(_id integer primary key autoincrement,time text);");      }      @override     public void onupgrade(sqlitedatabase db, int oldversion, int newversion) {         // todo auto-generated method stub         db.execsql("drop table if exists finalp");         oncreate(db);     }  } 

i want assign default value 50 column time.

i believe can this:

arg0.execsql("create table finalp(_id integer primary key autoincrement,time text default \'50\');"); 

and should work fine.

see sqlite docs column constraints. http://www.sqlite.org/syntaxdiagrams.html#column-constraint


Comments

Popular posts from this blog

Cursor error with postgresql, pgpool and php -

delphi - ESC/P programming! -

c++ - error: use of deleted function -