我有一个数据库如下。我想在创建表时将默认值写入此表
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);"
);
我应该怎么做?
答案 0 :(得分:1)
oncreate
中的使用for loop
在
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);"
);
循环调用createEntry
方法8次,并使用ContentValues