gpt4 book ai didi

java - E/SQLite日志: (1) table keyTable has no column named number

转载 作者:行者123 更新时间:2023-12-02 07:00:42 25 4
gpt4 key购买 nike

我不断收到此错误:

"table keyTable has no column named number"

对 Android 来说还是个新手,所以不知道为什么会发生这种情况,有人能发现这个错误吗?

这是我的数据库类:

public class KeyDatabase extends SQLiteOpenHelper {
private static final String database_name = "KeyDatabase.db";
private static final int database_version = 1;

KeyDatabase (Context context){
super(context,database_name,null,database_version);
}

@Override
public void onCreate (SQLiteDatabase db){
db.execSQL("CREATE TABLE " + KeyTableClass.table_name
+ "(" + KeyTableClass.id + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ KeyTableClass.number + " TEXT, "
+ KeyTableClass.key + " TEXT);");
}

public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion){
db.execSQL("DROP TABLE IF EXISTS " + KeyTableClass.table_name);
onCreate(db);
}

public long InsertKey (String number, String key){
ContentValues valuesToInsert = new ContentValues();

valuesToInsert.put(KeyTableClass.number, number);
valuesToInsert.put(KeyTableClass.key, key);

SQLiteDatabase sd = getWritableDatabase();

long result = sd.insert(KeyTableClass.table_name, KeyTableClass.number, valuesToInsert);

return result;
}

这是我的表的类:

public class KeyTableClass {
//The name of the table
public static final String table_name = "keyTable";

//The columns of the table
public static String id = "id";
public static String number = "number";
public static String key = "key";
}

最佳答案

也许您已经编辑了数据库 onCreate 但没有让它重新运行?尝试卸载/安装应用程序,或将 database_version 更新为 =2。

关于java - E/SQLite日志: (1) table keyTable has no column named number,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16700729/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com