我想清除一個具有自動增量鍵的表。Sqlite - 從sqlite_sequence刪除表時沒有這樣的列錯誤
我想通過我得到一個異常來做到以下幾點。
protected void clearSqliteSequenceTable(String table) {
String query = "delete from sqlite_sequence where name = business";
mDb.execSQL(query);
}
表名是商業。我得到以下沒有這樣的列業務例外。
09-11 15:53:33.709: E/AndroidRuntime(20204): FATAL EXCEPTION: main
09-11 15:53:33.709: E/AndroidRuntime(20204): Process: com.xx.xxx, PID: 20204
09-11 15:53:33.709: E/AndroidRuntime(20204): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.xx.xxx/com.xx.xxx.SplashActivity}: android.database.sqlite.SQLiteException: no such column: business (code 1): , while compiling: delete from sqlite_sequence where name = business
09-11 15:53:33.709: E/AndroidRuntime(20204): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
09-11 15:53:33.709: E/AndroidRuntime(20204): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
09-11 15:53:33.709: E/AndroidRuntime(20204): at android.app.ActivityThread.access$800(ActivityThread.java:135)
09-11 15:53:33.709: E/AndroidRuntime(20204): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
09-11 15:53:33.709: E/AndroidRuntime(20204): at android.os.Handler.dispatchMessage(Handler.java:102)
09-11 15:53:33.709: E/AndroidRuntime(20204): at android.os.Looper.loop(Looper.java:136)
09-11 15:53:33.709: E/AndroidRuntime(20204): at android.app.ActivityThread.main(ActivityThread.java:5001)
09-11 15:53:33.709: E/AndroidRuntime(20204): at java.lang.reflect.Method.invokeNative(Native Method)
09-11 15:53:33.709: E/AndroidRuntime(20204): at java.lang.reflect.Method.invoke(Method.java:515)
09-11 15:53:33.709: E/AndroidRuntime(20204): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
09-11 15:53:33.709: E/AndroidRuntime(20204): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
09-11 15:53:33.709: E/AndroidRuntime(20204): at dalvik.system.NativeStart.main(Native Method)
09-11 15:53:33.709: E/AndroidRuntime(20204): Caused by: android.database.sqlite.SQLiteException: no such column: business (code 1): , while compiling: delete from sqlite_sequence where name = business
09-11 15:53:33.709: E/AndroidRuntime(20204): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
09-11 15:53:33.709: E/AndroidRuntime(20204): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
09-11 15:53:33.709: E/AndroidRuntime(20204): at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
09-11 15:53:33.709: E/AndroidRuntime(20204): at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
09-11 15:53:33.709: E/AndroidRuntime(20204): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
09-11 15:53:33.709: E/AndroidRuntime(20204): at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
09-11 15:53:33.709: E/AndroidRuntime(20204): at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1672)
09-11 15:53:33.709: E/AndroidRuntime(20204): at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1603)
09-11 15:53:33.709: E/AndroidRuntime(20204): at com.xx.xxx.database.BaseDbAdapter.clearSqliteSequenceTable(BaseDbAdapter.java:65)
09-11 15:53:33.709: E/AndroidRuntime(20204): at com.xx.xxx.database.adapters.BusinessDbAdapter.clearSqliteSequenceTable(BusinessDbAdapter.java:149)
09-11 15:53:33.709: E/AndroidRuntime(20204): at com.xx.xxx.SplashActivity.insertDummyData(SplashActivity.java:79)
09-11 15:53:33.709: E/AndroidRuntime(20204): at com.xx.xxx.SplashActivity.onCreate(SplashActivity.java:51)
09-11 15:53:33.709: E/AndroidRuntime(20204): at android.app.Activity.performCreate(Activity.java:5231)
09-11 15:53:33.709: E/AndroidRuntime(20204): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
09-11 15:53:33.709: E/AndroidRuntime(20204): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
09-11 15:53:33.709: E/AndroidRuntime(20204): ... 11 more
我在哪裏結束雙引號? – 2014-09-11 10:42:49
對不起,忘了。請看我編輯的答案 – 2014-09-11 10:46:49