Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid sqlite select statement troubles
    primarykey
    data
    text
    <p>I am trying to get some data from a sqlite table named Course, with a attribute Name.</p> <p>I build the table here.</p> <pre><code>private static final String COURSE_ID = "CourseID"; private static final String COURSE_NAME = "Name"; private static final String COURSE_CODE = "CourseCode"; private static final String COURSE_ROWID = "_id"; private static final String COURSE_CREATE = "create table " + "Course" + " ( " + COURSE_ROWID + " integer primary key autoincrement, " + COURSE_ID + " integer not null," + COURSE_NAME + " text not null, " + COURSE_CODE + " text not null" + ");"; </code></pre> <p>I try to select my data with this function.</p> <pre><code> public Cursor getCourseNames() throws SQLException { String[] values = {COURSE_NAME}; mDb = mDbHelper.getReadableDatabase(); return mDb.query("Course",values, COURSE_ROWID + "=" + "Name", null, null, null, null, null); } </code></pre> <p>Then in my main class I execute it like this.</p> <pre><code> public void buildCoursetoChapterList(){ Cursor cursor = dbHelper.getCourseNames(); SimpleCursorAdapter adapter = new SimpleCursorAdapter(MainActivity.this, android.R.layout.simple_list_item_1, cursor, null, null); ListView listView = (ListView) findViewById(R.id.list); listView.setAdapter(adapter); } </code></pre> <p>I just want to grab the data and throw in in a list view, any idea what I am doing wrong? It seems like it is logical <code>Select from Course WHERE _id = "Name"</code>;</p> <p>Oh toot I forgot my error... java.lang.IllegalArgumentException: column '_id' does not exist</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.
 

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