2016-08-07 86 views
-3

這是我從android studio收到的日誌。NullPointerException:創建SQLite數據庫時

7月8日至7日:54:57.379 10573-10573/com.sifdon.shipping E/AndroidRuntime:致命異常:主 工藝:com.sifdon.shipping,PID:10573 了java.lang.RuntimeException:無法恢復活動{com.sifdon.shipping/com.sifdon.shipping.DisplayActivity}:java.lang.NullPointerException:試圖調用虛擬方法'android.database.sqlite.SQLiteDatabase com.sifdon.shipping.DbHelper.getWritableDatabase()'on一個空對象引用 at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3192) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3223) at android.app.ActivityThread.handleLaunchActi vity(ActivityThread.java:2471) at android.app.ActivityThread.access $ 1200(ActivityThread.java:152) at android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1341) at android.os.Handler .dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5538) at java.lang.reflect.Method .invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:960) at com。 android.internal.os.ZygoteIn it.main(ZygoteInit.java:755) 引起:java.lang.NullPointerException:嘗試調用空對象引用上的虛擬方法'android.database.sqlite.SQLiteDatabase com.sifdon.shipping.DbHelper.getWritableDatabase()' at com.sifdon.shipping.DisplayActivity.displayData(DisplayActivity.java:157) at com.sifdon.shipping.DisplayActivity.onResume(DisplayActivity.java:149) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java: 1249) 在android.app.Activity.performResume(Activity.java:6102) 在android.app.ActivityThread.performResumeActivity(ActivityThread.java:3167) 在android.app.ActivityThread.handleResumeActivity(ActivityTh read.java:3223) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471) at android.app.ActivityThread.access $ 1200(ActivityThread.java:152) at android.app.ActivityThread $ H.handleMessage (ActivityThread.java:1341) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread .java:5538) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:960) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 08-07 07:54:57.719 10573-10573/com.sifdon.shipping I /過程:發送信號。 PID:10573 SIG:9

+1

發佈您的創建數據庫部分代碼 –

+0

歡迎來到該網站,@Sifiso!我們確實需要導致此錯誤的代碼。您可能還想查看[如何提問](http://stackoverflow.com/help/how-to-ask)。 – Menasheh

回答

0

您在DisplayActivity當呼叫

DbHelper.getWritableDatabase()'NullPointerException。也許DbHelper是空的,你不能

從它調用任何方法。