→ The constructor of the Helper class for creating the b table is trying to create a new Main.db, but since Main.db has already been created, it cannot be newly created and onCreate of the b table is not called. , The table is not created and becomes no such table.
A_helper.java
public A_Helper(Context context) {
super(context, "Main.db", null, 1);
}
B_helper.java
public B_Helper(Context context) {
super(context, "Main.db", null, 1);
}
HogeHelper.java
public HogeHelper(Context context) {
super(context, "Main.db", null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
//Create table
db.execSQL("CREATE TABLE " + A_TABLE_NAME +
" (" + COLUMN_USER_ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
+ COLUMN_USER_NAME + " TEXT , "
+ COLUMN_USER_PASSWORD + " TEXT " + ");");
db.execSQL("CREATE TABLE " + B_TABLE_NAME +
" (" + COLUMN_BOOK_ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
+ COLUMN_BOOK_TITLE + " TEXT , "
+ COLUMN_BOOK_IMAGE + " TEXT , "
+ COLUMN_BOOK_REVIEW + " TEXT " + ");");
}
A_helper.java
public A_Helper(Context context) {
super(context, "Main.db", null, 1);
}
B_helper.java
public B_Helper(Context context) {
super(context, "Sub.db", null, 1);
}
Recommended Posts