0

我的代码:

private void filldata(){
    Cursor datacursor = sqlite.fetchalldata("Program");
    startManagingCursor(datacursor);

    String[] from = new String[]{DatabaseHelper.KEY_PROGRAM_DATE, DatabaseHelper.KEY_PROGRAM_TIME, DatabaseHelper.KEY_PROGRAM_CHANNEL};
    String[] from1 = new String[]{DatabaseHelper.KEY_PROGRAM_TITLE};

    int[] to = new int[]{R.id.programdate, R.id.programtime, R.id.programchannel};
    int[] to1 = new int[]{R.id.programtitle};

    SimpleExpandableListAdapter SEL = new SimpleExpandableListAdapter(this, 
                    createGroupList(), R.layout.programgroup_row, from1, to1,       
                    createChildList(), R.layout.programchild_row, from, to);
    setListAdapter( SEL );
}

当我打电话filldata()oncreate()Logcat给了我这个错误:

04-27 03:43:10.066: WARN/dalvikvm(279): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-27 03:43:10.146: ERROR/AndroidRuntime(279): FATAL EXCEPTION: main
04-27 03:43:10.146: ERROR/AndroidRuntime(279): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.imammuda/com.android.imammuda.ImamMuda}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.imammuda/com.android.imammuda.Program}: java.lang.NullPointerException
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.os.Looper.loop(Looper.java:123)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.main(ActivityThread.java:4627)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at java.lang.reflect.Method.invokeNative(Native Method)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at java.lang.reflect.Method.invoke(Method.java:521)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at dalvik.system.NativeStart.main(Native Method)
04-27 03:43:10.146: ERROR/AndroidRuntime(279): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.imammuda/com.android.imammuda.Program}: java.lang.NullPointerException
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.startActivityNow(ActivityThread.java:2503)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:651)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.widget.TabHost.setCurrentTab(TabHost.java:323)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.widget.TabHost.addTab(TabHost.java:213)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at com.android.imammuda.ImamMuda.onCreate(ImamMuda.java:26)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     ... 11 more
04-27 03:43:10.146: ERROR/AndroidRuntime(279): Caused by: java.lang.NullPointerException
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at com.android.imammuda.Program.createGroupList(Program.java:91)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at com.android.imammuda.Program.filldata(Program.java:45)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at com.android.imammuda.Program.onCreate(Program.java:29)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-27 03:43:10.146: ERROR/AndroidRuntime(279):     ... 20 more

*其他课程

Databasehelper extends SqliteOpenHelper

sqlite从/到open_closecreatedatafetchdatadatabasehelper

我想知道为什么我在使用函数时会收到此错误,而当我不调用它时却没有问题。

4

1 回答 1

0

NullPointer ExceptionProgram类行号 91 中命中。检查该行并尝试解决此空指针异常

于 2011-04-27T04:14:43.933 回答