Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems with populating a ListView with SQLite
    primarykey
    data
    text
    <p>I'm trying to populate my own SQLite db into the android listview for viewing but have a problem, the code runs but will generate an "unexpected quitting". </p> <p>I've checked my DDMS and the emulator has my SQLite file within the database which was copied from the assets file. </p> <p>I'm not sure what went wrong here, can anyone can give me some pointers where i should start looking from? Or is there anything even wrong with the code I've provided below ? Any where i can check for potential kinks in the code ? </p> <p>Thank you !!!</p> <pre><code>private void fillData() { Cursor drugsCursor = mDbHelper.fetchAllDrugs(); startManagingCursor(drugsCursor); //Creating an array to specify the fields we want String[] from = new String[] {DrugsDbAdapter.KEY_ROWID}; //and an array of the fields we want to bind in the view int[] to = new int[] {R.id.text1}; //To Create the simple cursor adapter and set it to display SimpleCursorAdapter drugs = new SimpleCursorAdapter(this, R.layout.drug_row, drugsCursor, from, to); setListAdapter(drugs); } </code></pre> <p>and the DrugsDbAdapter.java handling the Cursor is here</p> <pre><code>public Cursor fetchAllDrugs() { return mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_DRUG, KEY_CONTENT, KEY_INDICATION, KEY_DOSAGE, KEY_SPECIALPRECAUTION} , null, null, null, null, null); } </code></pre> <p>The output of my LogCat (the red color portion of the output- should i be posting the whole log?) is: </p> <pre><code>05-25 18:12:22.338: WARN/dalvikvm(27763): threadid=1: thread exiting with uncaught exception (group=0x4001d800) 05-25 18:12:22.434: ERROR/AndroidRuntime(27763): FATAL EXCEPTION: main 05-25 18:12:22.434: ERROR/AndroidRuntime(27763): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.paad.medboxsd/com.paad.medboxsd.medboxsd}: java.lang.NullPointerException 05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) 05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at android.os.Handler.dispatchMessage(Handler.java:99) 05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at android.os.Looper.loop(Looper.java:123) 05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at android.app.ActivityThread.main(ActivityThread.java:4627) 05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at java.lang.reflect.Method.invokeNative(Native Method) 05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at java.lang.reflect.Method.invoke(Method.java:521) 05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at dalvik.system.NativeStart.main(Native Method) 05-25 18:12:22.434: ERROR/AndroidRuntime(27763): Caused by: java.lang.NullPointerException 05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at com.paad.medboxsd.medboxsd.fillData(medboxsd.java:67) 05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at com.paad.medboxsd.medboxsd.onCreate(medboxsd.java:56) 05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 05-25 18:12:22.434: ERROR/AndroidRuntime(27763): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 05-25 18:12:22.434: ERROR/AndroidRuntime(27763): ... 11 more 05-25 18:12:22.514: WARN/ActivityManager(59): Force finishing activity com.paad.medboxsd/.medboxsd 05-25 18:12:23.034: WARN/ActivityManager(59): Activity pause timeout for HistoryRecord{450fc298 com.paad.medboxsd/.medboxsd} </code></pre>
    singulars
    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.
 

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