奇怪的异常随机引发(不在特定场景/模式中),异常如下所示"Caused by: android.database.sqlite.SQLiteException: no such table: Courses: , while compiling: SELECT * FROM Courses"
每次它运行完美但有时它会抛出异常,所以很明显数据库总是在那里,表也在该数据库中。
下面相关的 logcat 输出
11-29 01:16:02.570: E/AndroidRuntime(13916): FATAL EXCEPTION: main
11-29 01:16:02.570: E/AndroidRuntime(13916): java.lang.RuntimeException: Unable to resume activity {com.nobel.biocare/com.nobel.biocare.Courses_Events}: android.database.sqlite.SQLiteException: no such table: Courses: , while compiling: SELECT * FROM Courses
11-29 01:16:02.570: E/AndroidRuntime(13916): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2124)
11-29 01:16:02.570: E/AndroidRuntime(13916): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139)
11-29 01:16:02.570: E/AndroidRuntime(13916): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672)
11-29 01:16:02.570: E/AndroidRuntime(13916): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-29 01:16:02.570: E/AndroidRuntime(13916): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
11-29 01:16:02.570: E/AndroidRuntime(13916): at android.os.Handler.dispatchMessage(Handler.java:99)
11-29 01:16:02.570: E/AndroidRuntime(13916): at android.os.Looper.loop(Looper.java:123)
11-29 01:16:02.570: E/AndroidRuntime(13916): at android.app.ActivityThread.main(ActivityThread.java:3687)
11-29 01:16:02.570: E/AndroidRuntime(13916): at java.lang.reflect.Method.invokeNative(Native Method)
11-29 01:16:02.570: E/AndroidRuntime(13916): at java.lang.reflect.Method.invoke(Method.java:507)
11-29 01:16:02.570: E/AndroidRuntime(13916): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
11-29 01:16:02.570: E/AndroidRuntime(13916): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
11-29 01:16:02.570: E/AndroidRuntime(13916): at dalvik.system.NativeStart.main(Native Method)
11-29 01:16:02.570: E/AndroidRuntime(13916): Caused by: android.database.sqlite.SQLiteException: no such table: Courses: , while compiling: SELECT * FROM Courses
11-29 01:16:02.570: E/AndroidRuntime(13916): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
11-29 01:16:02.570: E/AndroidRuntime(13916): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)
11-29 01:16:02.570: E/AndroidRuntime(13916): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65)
11-29 01:16:02.570: E/AndroidRuntime(13916): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83)
11-29 01:16:02.570: E/AndroidRuntime(13916): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:49)
11-29 01:16:02.570: E/AndroidRuntime(13916): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
11-29 01:16:02.570: E/AndroidRuntime(13916): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1356)
11-29 01:16:02.570: E/AndroidRuntime(13916): at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1235)
11-29 01:16:02.570: E/AndroidRuntime(13916): at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1189)
11-29 01:16:02.570: E/AndroidRuntime(13916): at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1271)
11-29 01:16:02.570: E/AndroidRuntime(13916): at com.nobel.biocare.database.DBHelper.read_Courses(DBHelper.java:444)
11-29 01:16:02.570: E/AndroidRuntime(13916): at com.nobel.biocare.Courses_Events.onResume(Courses_Events.java:131)
11-29 01:16:02.570: E/AndroidRuntime(13916): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1150)
11-29 01:16:02.570: E/AndroidRuntime(13916): at android.app.Activity.performResume(Activity.java:3832)
11-29 01:16:02.570: E/AndroidRuntime(13916): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2114)
11-29 01:16:02.570: E/AndroidRuntime(13916): ... 12 more
下面是 DBHelper 类的相关代码片段
public Cursor read_Courses(SQLiteDatabase db) {
return db.query(TBL_Courses, null, null, null, null, null, null);
}
下面是相关的活动代码片段
protected void onResume() {
super.onResume();
MyOpenDB();
setTab_Images(Common.Courses_Events);
if (!myApp.checkNetworkRechability()) {
Show_No_Internet();
}
if (is_DB_DBHelper_Null() && isDBOpen()) {
fetch_Courses_from_DB(dbHelper.read_Courses(MyDb));
fetch_Events_from_DB(dbHelper.read_Events(MyDb));
}
}
我对如何解决这个异常一无所知。