嗨,任何人都可以帮助解决这个问题..
这是我的DatabaseHelper.java代码
linkedlist<>
我的logcat显示此错误
07-19 08:28:06.444 2522-2522 / com.example.myapplication E / SQLiteLog:(1)没有这样的表:座位
答案 0 :(得分:0)
看起来没有创建Seat表。在尝试添加数据之前,您需要确保调用onCreate()。
如果您对数据库进行了更改,则可能需要onUpgrade()方法以确保正确调用onCreate:
public class DatabaseHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "YOUR_DATABASE_NAME;
// Increment this when you make changes
private static final int DATABASE_VERSION = 2;
public MyDatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
// This will delete your old database, but that's probably ok since it's not yet working.
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
database.execSQL("DROP TABLE IF EXISTS " + TABLE_SEATS);
onCreate(database);
}
// plus the code you have above
...
}