Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid column '_id' does not exist?
    primarykey
    data
    text
    <p>I'm having trouble with something that works in the Notepad example. Here's the code from the NotepadCodeLab/Notepadv1Solution:</p> <pre><code>String[] from = new String[] { NotesDbAdapter.KEY_TITLE }; int[] to = new int[] { R.id.text1 }; SimpleCursorAdapter notes = new SimpleCursorAdapter(this, R.layout.notes_row, c, from, to); </code></pre> <p>This code seems to work fine. But just to be clear, I ran the <a href="http://android-dls.com/wiki/index.php?title=ADB" rel="noreferrer">ADB</a> utility and run SQLite 3. I inspected the schema as follows:</p> <p>sqlite> .schema</p> <pre><code>CREATE TABLE android_metadata (locale TEXT); CREATE TABLE notes (_id integer primary key autoincrement, title text not null, body text not null); </code></pre> <p>All seems good to me.</p> <hr> <p>Now on to my application, which, as far as I can see, is basically the same with a few minor changes. I've simplified and simplified my code, but the problem persists.</p> <pre><code>String[] from = new String[] { "x" }; int[] to = new int[] { R.id.x }; SimpleCursorAdapter adapter = null; try { adapter = new SimpleCursorAdapter(this, R.layout.circle_row, cursor, from, to); } catch (RuntimeException e) { Log.e("Circle", e.toString(), e); } </code></pre> <p>When I run my application, I get a RuntimeException and the following prints in LogCat from my <code>Log.e()</code> statement:</p> <p>LogCat Message:</p> <blockquote> <p>java.lang.IllegalArgumentException: column '_id' does not exist</p> </blockquote> <p>So, back to SQLite 3 to see what's different about my schema:</p> <p>sqlite> .schema CREATE TABLE android_metadata (locale TEXT); CREATE TABLE circles (_id integer primary key autoincrement, sequence integer, radius real, x real, y real);</p> <p>I don't see how I'm missing the '_id'.</p> <p>What have I done wrong?</p> <p>One thing that's different between my application and the Notepad example is that I started by creating my application from scratch using the Eclipse wizard while the sample application comes already put together. Is there some sort of environmental change I need to make for a new application to use a SQLite database?</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.
 

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