我想管理(创建/删除/更新)一个有 18 列的表。通常,为了创建表格,我使用以下代码。有没有更聪明的方法,比如将列名放入数组等?人们如何处理大桌子?
一如既往地感谢您的帮助。
private static final String COL1 = "col1";
private static final String COL2 = "col2";
private static final String COL3 = "col3";
........
........
private static final String COL18 = "col18";
public dbhandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + "("
+ COL1 + " INTEGER PRIMARY KEY," + COL2 + " TEXT,"
+ COL3 + " TEXT," + .............................+ COL18 + " TEXT")";
db.execSQL(CREATE_TABLE);
}