2012-03-06 115 views
0

我得到這段代碼的運行時錯誤。我的錯誤是什麼?Android SQLite光標錯誤

String myPath = DB_PATH + DB_NAME; 
myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); 
Cursor cur = myDataBase.rawQuery("SELECT * FROM personel" , null);  
cur.moveToFirst(); 
cur.close(); 
myDataBase.close(); 

這是我的logcat:

這是我的logcat:

03-06 14:35:14.821: E/AndroidRuntime(11995): FATAL EXCEPTION: main 
03-06 14:35:14.821: E/AndroidRuntime(11995): java.lang.RuntimeException: Unable to start activity ComponentInfo{Dic.proj.pkg/Dic.proj.pkg.DictionaryActivity}: android.database.sqlite.SQLiteException: no such table: personel: , while compiling: Select * from personel 
03-06 14:35:14.821: E/AndroidRuntime(11995): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647) 
03-06 14:35:14.821: E/AndroidRuntime(11995): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663) 
03-06 14:35:14.821: E/AndroidRuntime(11995): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 
03-06 14:35:14.821: E/AndroidRuntime(11995): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931) 
03-06 14:35:14.821: E/AndroidRuntime(11995): at android.os.Handler.dispatchMessage(Handler.java:99) 
03-06 14:35:14.821: E/AndroidRuntime(11995): at android.os.Looper.loop(Looper.java:123) 
03-06 14:35:14.821: E/AndroidRuntime(11995): at android.app.ActivityThread.main(ActivityThread.java:3683) 
03-06 14:35:14.821: E/AndroidRuntime(11995): at java.lang.reflect.Method.invokeNative(Native Method) 
03-06 14:35:14.821: E/AndroidRuntime(11995): at java.lang.reflect.Method.invoke(Method.java:507) 
03-06 14:35:14.821: E/AndroidRuntime(11995): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 
03-06 14:35:14.821: E/AndroidRuntime(11995): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 
03-06 14:35:14.821: E/AndroidRuntime(11995): at dalvik.system.NativeStart.main(Native Method) 
03-06 14:35:14.821: E/AndroidRuntime(11995): Caused by: android.database.sqlite.SQLiteException: no such table: personel: , while compiling: Select * from personel 
03-06 14:35:14.821: E/AndroidRuntime(11995): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method) 
03-06 14:35:14.821: E/AndroidRuntime(11995): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92) 
03-06 14:35:14.821: E/AndroidRuntime(11995): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65) 
03-06 14:35:14.821: E/AndroidRuntime(11995): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83) 
03-06 14:35:14.821: E/AndroidRuntime(11995): at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:49) 
03-06 14:35:14.821: E/AndroidRuntime(11995): at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42) 
03-06 14:35:14.821: E/AndroidRuntime(11995): at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1356) 
03-06 14:35:14.821: E/AndroidRuntime(11995): at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1324) 
03-06 14:35:14.821: E/AndroidRuntime(11995): at Dic.proj.pkg.DataBaseHelper.getCount(DataBaseHelper.java:126) 
03-06 14:35:14.821: E/AndroidRuntime(11995): at Dic.proj.pkg.DictionaryActivity.onCreate(DictionaryActivity.java:44) 
03-06 14:35:14.821: E/AndroidRuntime(11995): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 
03-06 14:35:14.821: E/AndroidRuntime(11995): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611) 
+3

** What ** err或者你越來越? – Mat 2012-03-06 09:29:10

+2

發佈錯誤日誌...圖片太模糊。 – drulabs 2012-03-06 09:32:47

+0

當我運行我的程序時,我在錯誤日誌中沒有得到任何錯誤。但在模擬器中我得到這個錯誤:應用程序App_name意外停止。請再試一次 – Fcoder 2012-03-06 09:39:11

回答

1

你可能已經包含了「企業人事」表最近&沒有升級的數據庫版本,或者您可能已經改變了defenition of「personel」,所以儘量在這裏增加DataBase-Version:

public DatabaseHelper(Context context) 
{ 
    super(context, dbName, null,Increment the value here); 
}