Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't get any data from sqlite db on Android
    primarykey
    data
    text
    <p>I have a DB helper that does this function:</p> <pre><code>public Cursor getCourseNames() throws SQLException { mDb = mDbHelper.getReadableDatabase(); return mDb.query("Course",null, COURSE_ROWID, null, null, null, null, null); } </code></pre> <p>The table it is pulling from looks like this:</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>In my main activity I try this and get a null pointer...</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>Anyone have an idea what my problem is? I put data into the db earlier on: </p> <pre><code>if(dbHelper.checkCourseForData() !=null) { setContentView(R.layout.classlist); } else { dbHelper.addFirstClassToDb(course_code, name, course_id); Log.d+i("Course added to DB", course_code + " " + name + " " + course_id); } </code></pre> <p>tried this and still nothing, I want to select all the Name values within Course. No clue... losing hope.</p> <pre><code>public Cursor checkCourseForData() throws SQLException { String[] values = {COURSE_NAME}; Cursor mCursor = mDb.query("Course",values,COURSE_ROWID + "=" + "Name", null, null, null, null, null); if (mCursor != null) { mCursor.moveToFirst(); } return mCursor; } </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