我正在尝试插入此表,我不断收到标题中的消息。以下是相关代码:
public static final String CREDENTIALS = "_credentials";
public static final String AUTOFILL = "LAST_USER";
public static final String EXT_CONFIG = "external_config";
public static final String ANDROID_CONFIG = "android_config";
private static final int DATABASE_VERSION = 1;
static final String DATABASE_NAME = "dreapp";
private static final String TABLE_CONFIG = "config_table";
private static final String KEY_ID = "id";
private static final String KEY_NAME = "name";
private static final String KEY_CONTENT = "content";
private static final String IMAGE_TABLE = "image_table";
private static final String EVAL_TABLE = "eval_table";
private static final String CREDENTIAL_TABLE = "credential_table";
private static final String KEY_USER = "user";
private static final String KEY_JSON = "json";
private static final String KEY_ARRESTEE = "arrestee_name";
private static final String ID_EVAL = "evalId";
private static final String IMAGE_TYPE = "image_type";
private static final String IMAGE_BLOB = "image";
@Override
public void onCreate(SQLiteDatabase db) {
Log.i("ITSMR", "Hello!");
String CREATE_CONTACTS_TABLE = "CREATE TABLE IF NOT EXISTS " + TABLE_CONFIG + " ("
+ KEY_ID + " INTEGER PRIMARY KEY," + KEY_NAME + " TEXT, "
+ KEY_CONTENT + " TEXT" + ")";
db.execSQL(CREATE_CONTACTS_TABLE);
String CREATE_EVAL_TABLE = "CREATE TABLE IF NOT EXISTS " + EVAL_TABLE + " (" + KEY_ID + " INTEGER PRIMARY KEY,"
+ KEY_USER + " TEXT, " + KEY_JSON + " TEXT, " + KEY_ARRESTEE + " TEXT" + ")";
db.execSQL(CREATE_EVAL_TABLE);
String CREATE_IMAGE_TABLE = "CREATE TABLE IF NOT EXISTS " + IMAGE_TABLE + " (" + KEY_ID + " INTEGER PRIMARY KEY,"
+ ID_EVAL + " INTEGER, " + IMAGE_TYPE + " TEXT, " + IMAGE_BLOB + " BLOB" + ")";
db.execSQL(CREATE_IMAGE_TABLE);
String CREATE_CREDENTIAL_TABLE = "CREATE TABLE IF NOT EXISTS " + CREDENTIAL_TABLE + " ("
+ KEY_ID + " INTEGER PRIMARY KEY," + KEY_NAME + " TEXT, "
+ KEY_CONTENT + " TEXT" + ")";
db.execSQL(CREATE_CREDENTIAL_TABLE);
}
public void addCredential(DREConfig credential){
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(KEY_NAME, credential.getKey());
values.put(KEY_CONTENT, credential.getContent());
db.insert(CREDENTIAL_TABLE, null, values);
db.close();
}
我发现一些问题,卸载应用程序修复了这个问题。这在我的情况下不起作用。我仍然得到完全相同的错误。我一直在搞这个很长一段时间,我需要帮助。
这是错误: 08-04 13:36:52.016:E / SQLiteLog(24977):( 1)表凭证_table没有名为content的列
08-04 13:36:52.021:E / SQLiteDatabase(24977):插入内容时出错= OTester name = OTester_credentials 08-04 13:36:52.021:E / SQLiteDatabase(24977):android.database.sqlite.SQLiteException:table credential_table没有列名为content(code 1):,编译时:INSERT INTO credential_table(content,name)VALUES( ?,?)
感谢。