2012-10-28 85 views
-1

在beginnig所有的工作確定,但我已經通過命令刪除數據庫後:的Android的SQLite得到數據庫

this.deleteDatabase("databasename"); 

,然後我的命令:

databasehelper.getWritableDatabase(); 

開始扔產生的異常

10-28 23:39:29.190: D/AndroidRuntime(15363): Shutting down VM 
10-28 23:39:29.190: W/dalvikvm(15363): threadid=1: thread exiting with uncaught exception (group=0x40b5b300) 
10-28 23:39:29.190: E/AndroidRuntime(15363): FATAL EXCEPTION: main 
10-28 23:39:29.190: E/AndroidRuntime(15363): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.package/com.package.MainActivity}: java.lang.ArrayIndexOutOfBoundsException: length=50; index=50 
10-28 23:39:29.190: E/AndroidRuntime(15363): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059) 
10-28 23:39:29.190: E/AndroidRuntime(15363): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 
10-28 23:39:29.190: E/AndroidRuntime(15363): at android.app.ActivityThread.access$600(ActivityThread.java:130) 
10-28 23:39:29.190: E/AndroidRuntime(15363): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 
10-28 23:39:29.190: E/AndroidRuntime(15363): at android.os.Handler.dispatchMessage(Handler.java:99) 
10-28 23:39:29.190: E/AndroidRuntime(15363): at android.os.Looper.loop(Looper.java:137) 
10-28 23:39:29.190: E/AndroidRuntime(15363): at android.app.ActivityThread.main(ActivityThread.java:4745) 
10-28 23:39:29.190: E/AndroidRuntime(15363): at java.lang.reflect.Method.invokeNative(Native Method) 
10-28 23:39:29.190: E/AndroidRuntime(15363): at java.lang.reflect.Method.invoke(Method.java:511) 
10-28 23:39:29.190: E/AndroidRuntime(15363): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
10-28 23:39:29.190: E/AndroidRuntime(15363): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
10-28 23:39:29.190: E/AndroidRuntime(15363): at dalvik.system.NativeStart.main(Native Method) 
10-28 23:39:29.190: E/AndroidRuntime(15363): Caused by: java.lang.ArrayIndexOutOfBoundsException: length=50; index=50 
10-28 23:39:29.190: E/AndroidRuntime(15363): at com.package.DBHelper.onCreate(DBHelper.java:41) 
10-28 23:39:29.190: E/AndroidRuntime(15363): at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:252) 
10-28 23:39:29.190: E/AndroidRuntime(15363): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164) 
10-28 23:39:29.190: E/AndroidRuntime(15363): at com.package.MainActivity.onCreate(MainActivity.java:28) 
10-28 23:39:29.190: E/AndroidRuntime(15363): at android.app.Activity.performCreate(Activity.java:5008) 
10-28 23:39:29.190: E/AndroidRuntime(15363): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079) 
10-28 23:39:29.190: E/AndroidRuntime(15363): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023) 
10-28 23:39:29.190: E/AndroidRuntime(15363): ... 11 more 

現在我該怎麼辦?

+0

PS:databasehelper.getDatabaseName(); - 作品 –

+0

Post'com.package.DBHelper.onCreate()' – Raffaele

回答

1

您應該學會如何閱讀堆棧跟蹤,因爲它們是現代語言的一個不可估量的特性。您的Activity不能啓動,因爲試圖在索引50在具有50個元素的陣列,以訪問該元素,並且因此允許在0和49之間的索引:

java.lang.ArrayIndexOutOfBoundsException: length=50; index=50 

這個位於的com.package.DBHelperonCreate()方法,在第41行

+0

哦。非常感謝你。 –

0

可能需要先重新創建數據庫嗎?

+0

我在輸入命令之前完成了它。 –