我有一个工作表(一个名为 DATABASE_CREATE1),该表仍然工作,但是当我尝试将数据插入第二个表时,我得到了这个错误,不知道如何修复它尝试了很长时间关于如何修复它,但没有任何想法:
06-13 23:56:21.179: E/Database(8840): android.database.sqlite.SQLiteException: table quick_mute has no column named row_id_quick_mute: , while compiling: INSERT INTO quick_mute(row_id_quick_mute, alarm_id) VALUES(?, ?);
06-13 23:56:21.179: E/Database(8840): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
06-13 23:56:21.179: E/Database(8840): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)
06-13 23:56:21.179: E/Database(8840): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65)
06-13 23:56:21.179: E/Database(8840): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83)
06-13 23:56:21.179: E/Database(8840): at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:41)
06-13 23:56:21.179: E/Database(8840): at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1149)
06-13 23:56:21.179: E/Database(8840): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1569)
06-13 23:56:21.179: E/Database(8840): at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1426)
06-13 23:56:21.179: E/Database(8840): at com.seanoneill.android.SilentPhone.DatabaseStore.createQuickMuteEntry(DatabaseStore.java:316)
06-13 23:56:21.179: E/Database(8840): at com.seanoneill.android.SilentPhone.HoldsEverything$1.onClick(HoldsEverything.java:163)
06-13 23:56:21.179: E/Database(8840): at android.view.View.performClick(View.java:2485)
06-13 23:56:21.179: E/Database(8840): at android.view.View$PerformClick.run(View.java:9080)
06-13 23:56:21.179: E/Database(8840): at android.os.Handler.handleCallback(Handler.java:587)
06-13 23:56:21.179: E/Database(8840): at android.os.Handler.dispatchMessage(Handler.java:92)
06-13 23:56:21.179: E/Database(8840): at android.os.Looper.loop(Looper.java:123)
06-13 23:56:21.179: E/Database(8840): at android.app.ActivityThread.main(ActivityThread.java:3729)
06-13 23:56:21.179: E/Database(8840): at java.lang.reflect.Method.invokeNative(Native Method)
06-13 23:56:21.179: E/Database(8840): at java.lang.reflect.Method.invoke(Method.java:507)
06-13 23:56:21.179: E/Database(8840): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:874)
06-13 23:56:21.179: E/Database(8840): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:632)
06-13 23:56:21.179: E/Database(8840): at dalvik.system.NativeStart.main(Native Method)
代码:
private static final String DATABASE_CREATE =
"create table " + DATABASE_TABLE_QUICK + " ("
+ kEY_ROWID_QUICK_MUTE + "text not null, "
+ END_TIME_QUICK + " text not null,"
+ ALARM_ID_QUICK + " text not null );";
private static final String DATABASE_CREATE1=
"create table " + DATABASE_TABLE + " ("
+ kEY_ROWID + " integer primary key autoincrement, "
+ END_KEY_TIME + " text not null,"
+ START_TIME_12_HOUR + " text not null,"
+ END_TIME_12_HOUR + " text not null,"
+ COVERT_DAYS + " text not null,"
+ KEY_STATE + " text not null,"
+ MUTE_TITLE + " text not null, "
+ ALARM_MODE + " text not null, "
+ALARM_ID+ " text not null,"
+ START_KEY_TIME + " text not null );";
创建数据库
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(DATABASE_CREATE);
db.execSQL(DATABASE_CREATE1);
}
这是插入数据库的代码
public void createQuickMuteEntry(String endTime, String alarmid) {
ContentValues initialValues = new ContentValues();
initialValues.put(kEY_ROWID_QUICK_MUTE, endTime ); /
initialValues.put(ALARM_ID, alarmid);
databaseConnect.insert(DATABASE_TABLE_QUICK, null, initialValues);
}
插入语句
getDatabaseInfo.createQuickMuteEntry("dfdf", "dfdf");
update: //快速静音
public static final String END_TIME_QUICK = "quick_mute_end_time";
public static final String ALARM_ID_QUICK = "quick_mute_id";
public static final String kEY_ROWID_QUICK_MUTE = "row_id_quick_mute";