Note that there are some explanatory texts on larger screens.

plurals
  1. PObad request for field slot 0 -1. numRows= 10, numColumn = 1
    primarykey
    data
    text
    <p>I have an activity that shows the results of a search (in my database) in a two listview. The problem is that the application always crashes every time I run the apps. This is what the logcat shows me :</p> <pre><code>07-02 12:42:15.940: E/CursorWindow(23645): Bad request for field slot 0,1. numRows = 10, numColumns = 1 07-02 12:42:15.980: E/AndroidRuntime(23645): FATAL EXCEPTION: main 07-02 12:42:15.980: E/AndroidRuntime(23645): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.series3/com.example.series3.FindMePlace}: java.lang.IllegalStateException: get field slot from row 0 col 1 failed 07-02 12:42:15.980: E/AndroidRuntime(23645): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647) 07-02 12:42:15.980: E/AndroidRuntime(23645): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663) 07-02 12:42:15.980: E/AndroidRuntime(23645): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 07-02 12:42:15.980: E/AndroidRuntime(23645): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931) 07-02 12:42:15.980: E/AndroidRuntime(23645): at android.os.Handler.dispatchMessage(Handler.java:99) 07-02 12:42:15.980: E/AndroidRuntime(23645): at android.os.Looper.loop(Looper.java:123) 07-02 12:42:15.980: E/AndroidRuntime(23645): at android.app.ActivityThread.main(ActivityThread.java:3683) 07-02 12:42:15.980: E/AndroidRuntime(23645): at java.lang.reflect.Method.invokeNative(Native Method) 07-02 12:42:15.980: E/AndroidRuntime(23645): at java.lang.reflect.Method.invoke(Method.java:507) 07-02 12:42:15.980: E/AndroidRuntime(23645): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 07-02 12:42:15.980: E/AndroidRuntime(23645): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 07-02 12:42:15.980: E/AndroidRuntime(23645): at dalvik.system.NativeStart.main(Native Method) 07-02 12:42:15.980: E/AndroidRuntime(23645): Caused by: java.lang.IllegalStateException: get field slot from row 0 col 1 failed 07-02 12:42:15.980: E/AndroidRuntime(23645): at android.database.CursorWindow.getString_native(Native Method) 07-02 12:42:15.980: E/AndroidRuntime(23645): at android.database.CursorWindow.getString(CursorWindow.java:329) 07-02 12:42:15.980: E/AndroidRuntime(23645): at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:49) 07-02 12:42:15.980: E/AndroidRuntime(23645): at com.example.series3.DatabaseHandler.getAllFromLocation(DatabaseHandler.java:737) 07-02 12:42:15.980: E/AndroidRuntime(23645): at com.example.series3.FindMePlace.populateFromLocation(FindMePlace.java:108) 07-02 12:42:15.980: E/AndroidRuntime(23645): at com.example.series3.FindMePlace.onCreate(FindMePlace.java:53) 07-02 12:42:15.980: E/AndroidRuntime(23645): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 07-02 12:42:15.980: E/AndroidRuntime(23645): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611) </code></pre> <p>here is part of my code.</p> <p><strong>FindMePlace.java</strong></p> <pre><code> private void populateToDestination() { List&lt;UkmRoute&gt; destination = db.getAllToDestination(); for (UkmRoute k : destination) { results.add(k.getToDestination()); results_id.add(k.getID()); } if (!filterText2.getText().toString().equals("")) adapter = new ArrayAdapter&lt;String&gt;(FindMePlace.this, R.layout.list_item, R.id.textView1, results); else { ArrayList&lt;String&gt; r = new ArrayList&lt;String&gt;(); adapter = new ArrayAdapter&lt;String&gt;(FindMePlace.this, R.layout.list_item, R.id.textView1, r); } setListAdapter(adapter); // Set ListView from ListActivity ListView lv2 = getListView(); lv2.setTextFilterEnabled(true); // Set click event from listView lv2.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { // When clicked, show a toast with the TextView text Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show(); Log.d("test", "position:" + position); Log.d("test", "actualname:" + db.getUkmRouteByTo(adapter.getItem(position)) .getFromLocation()); // String poiID = results_id.get(position); String poiID = db.getUkmRouteByTo(adapter.getItem(position)) .getID(); setSelectedPoi(poiID); // startActivity(c); } }); } private void populateFromLocation() { // Reading location Log.d("Reading", "Reading all location .."); List&lt;UkmRoute&gt; location = db.getAllFromLocation(); for (UkmRoute k : location) { results.add(k.getFromLocation()); results_id.add(k.getID()); } // Set list arrayAdapter to adapter if (!filterText.getText().toString().equals("")) adapter = new ArrayAdapter&lt;String&gt;(FindMePlace.this, R.layout.list_item, R.id.textView1, results); else { ArrayList&lt;String&gt; r = new ArrayList&lt;String&gt;(); adapter = new ArrayAdapter&lt;String&gt;(FindMePlace.this, R.layout.list_item, R.id.textView1, r); } // adapter = new ArrayAdapter&lt;String&gt;(this, R.layout.list_item, // R.id.textView1, results); setListAdapter(adapter); // Set ListView from ListActivity ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { // When clicked, show a toast with the TextView text Toast.makeText(getApplicationContext(), ((TextView) view).getText(), Toast.LENGTH_SHORT).show(); Log.d("test", "position:" + position); Log.d("test", "actualname:" + db.getUkmRouteByFrom( adapter.getItem(position)) .getFromLocation()); // String poiID = results_id.get(position); String poiID = db.getUkmRouteByFrom(adapter.getItem(position)) .getID(); setSelectedPoi(poiID); // startActivity(c); } }); } </code></pre> <p><strong>DatabaseHandler.java</strong></p> <pre><code>public List&lt;UkmRoute&gt; getAllToDestination() { List&lt;UkmRoute&gt; ToList = new ArrayList&lt;UkmRoute&gt;(); //Select All Query String selectQuery = "SELECT DISTINCT ToDestination FROM " + TABLE_UKMROUTE; SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); //looping through all rows and adding to list if (cursor.moveToFirst()) { do { UkmRoute poi = new UkmRoute(); poi.setID(cursor.getString(0)); poi.setFromLocation(cursor.getString(1)); poi.setToDestination(cursor.getString(2)); poi.setRoute1(cursor.getString(3)); poi.setRoute2(cursor.getString(4)); //Adding kategori to list ToList.add(poi); } while (cursor.moveToNext()); } // return Kategori list return ToList; } public List&lt;UkmRoute&gt; getAllFromLocation() { List&lt;UkmRoute&gt; ToList = new ArrayList&lt;UkmRoute&gt;(); //Select All Query String selectQuery = "SELECT DISTINCT FromLocation FROM " + TABLE_UKMROUTE; SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.rawQuery(selectQuery, null); //looping through all rows and adding to list if (cursor.moveToFirst()) { do { UkmRoute poi = new UkmRoute(); poi.setID(cursor.getString(0)); poi.setFromLocation(cursor.getString(1)); poi.setToDestination(cursor.getString(2)); poi.setRoute1(cursor.getString(3)); poi.setRoute2(cursor.getString(4)); //Adding kategori to list ToList.add(poi); } while (cursor.moveToNext()); } // return Kategori list return ToList; } </code></pre> <p>is there anything wrong with my sql query?</p> <pre><code>String selectQuery = "SELECT DISTINCT ToDestination FROM " + TABLE_UKMROUTE; </code></pre>
    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.
    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