我有 2 个表 Employee 和 order 表,我试图将这些表实现到同一个数据库助手类中,但是这给了我几个错误,我应该创建另一个数据库助手类,还是我可以将它们实现到一个数据库助手类中表看起来像这样`public class DatabaseHelper extends SQLiteOpenHelper { private static final String DB_NAME = "shopinstyle.db"; private static final String DB_TABLE = "Employee"; private static final String ORDER_TABLE = "Order"; //Employee //columns private static final String ID = "ID"; private static final String FNAME = "FNAME"; private static final String LNAME = "LNAME"; private static final String PNUMBER = "PNUMBER"; private static final String EMAIL = "EMAIL"; private static final String NIC = "NIC"; //Order //columns private static final String ord_ID = "ord_ID"; private static final String ord_Name = "ord_Name"; private static final String ord_Qty = "ord_Qty"; private static final String ord_Price = "ord_Price"; private static final String ord_Location = "ord_Location"; private static final String CREATE_TABLE = "CREATE TABLE " + DB_TABLE + " (" + ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + FNAME + " TEXT, " + LNAME + " TEXT, " + PNUMBER + " TEXT, " + EMAIL + " TEXT, " + NIC + " TEXT" + ")"; private static final String CREATE_TABLE_ORDER = "CREATE TABLE " + ORDER_TABLE + " (" + ord_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + ord_Name + " TEXT, " + ord_Qty + " TEXT, " + ord_Price + " TEXT, " + ord_Location + " TEXT " + ")"; public DatabaseHelper(Context context) { super(context, DB_NAME,ORDER_TABLE, null, 1); } @Override public void onCreate(SQLiteDatabase sqLiteDatabase) { sqLiteDatabase.execSQL(CREATE_TABLE); sqLiteDatabase.execSQL(CREATE_TABLE_ORDER); }这行有一个错误public DatabaseHelper(Context context) { super(context, DB_NAME,ORDER_TABLE, null, 1);}
1 回答
FFIVE
TA贡献1797条经验 获得超6个赞
super()
类的构造函数内部的cal 中的 3d 参数DatabaseHelper
是factory
您可以传递的参数null
,而不是表的名称:
super(context, DB_NAME,null, 1);
添加回答
举报
0/150
提交
取消