Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't show data on spinner? throws Null Pointer Exception
    primarykey
    data
    text
    <p>can anyone tell wats wrong in this code... I put code bellow.</p> <pre><code>mySQLiteAdapter = new SQLiteAdapter(this); cursor = mySQLiteAdapter.displayCategory(); startManagingCursor(cursor); String[] from = new String[] { SQLiteAdapter.KEY_ID, SQLiteAdapter.KEY_CATEGORY }; int[] to = new int[] { android.R.id.text1 }; mCategory = (Spinner) findViewById(R.id.choose_category); SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, cursor, from, to); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mCategory.setAdapter(adapter); </code></pre> <p>MyAdapter class having following code </p> <pre><code>public Cursor displayCategory() { String[] columns = new String[]{KEY_ID, KEY_CATEGORY}; Cursor cursor = sqLiteDatabase.query(MYCATEGORY_TABLE, columns, null, null, null, null, null); return cursor; </code></pre> <p>Null pointer Exception. How to avoid it. This is the error on log cat</p> <pre><code> 09-09 15:49:16.535: ERROR/AndroidRuntime(6526): Uncaught handler: thread main exiting due to uncaught exception 09-09 15:49:16.545: ERROR/AndroidRuntime(6526): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.mpt.receiptor/com.android.mpt.receiptor.SearchReceipt}: java.lang.NullPointerException 09-09 15:49:16.545: ERROR/AndroidRuntime(6526): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496) 09-09 15:49:16.545: ERROR/AndroidRuntime(6526): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512) 09-09 15:49:16.545: ERROR/AndroidRuntime(6526): at android.app.ActivityThread.access$2200(ActivityThread.java:119) 09-09 15:49:16.545: ERROR/AndroidRuntime(6526): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) 09-09 15:49:16.545: ERROR/AndroidRuntime(6526): at android.os.Handler.dispatchMessage(Handler.java:99) 09-09 15:49:16.545: ERROR/AndroidRuntime(6526): at android.os.Looper.loop(Looper.java:123) 09-09 15:49:16.545: ERROR/AndroidRuntime(6526): at android.app.ActivityThread.main(ActivityThread.java:4363) 09-09 15:49:16.545: ERROR/AndroidRuntime(6526): at java.lang.reflect.Method.invokeNative(Native Method) 09-09 15:49:16.545: ERROR/AndroidRuntime(6526): at java.lang.reflect.Method.invoke(Method.java:521) 09-09 15:49:16.545: ERROR/AndroidRuntime(6526): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 09-09 15:49:16.545: ERROR/AndroidRuntime(6526): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 09-09 15:49:16.545: ERROR/AndroidRuntime(6526): at dalvik.system.NativeStart.main(Native Method) 09-09 15:49:16.545: ERROR/AndroidRuntime(6526): Caused by: java.lang.NullPointerException 09-09 15:49:16.545: ERROR/AndroidRuntime(6526): at com.android.mpt.receiptor.SQLiteAdapter.displayCategory(SQLiteAdapter.java:135) 09-09 15:49:16.545: ERROR/AndroidRuntime(6526): at com.android.mpt.receiptor.SearchReceipt.onCreate(SearchReceipt.java:96) 09-09 15:49:16.545: ERROR/AndroidRuntime(6526): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 09-09 15:49:16.545: ERROR/AndroidRuntime(6526): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459) </code></pre> <p>Pls someone help me.</p> <p>Thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload