I'm having problems with something that works in the notepad example. Here is the code from NotepadCodeLab / Notepadv1Solution:
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);
This code is working fine. But to be clear, I ran the ADB utility and run SQLite 3. I checked the schema as follows:
sqlite> .schema
CREATE TABLE android_metadata (locale TEXT); CREATE TABLE notes (_id integer primary key autoincrement, title text not null, body text not null);
I'm fine.
Now in my application, which, as far as I see, is basically the same with a few minor changes. I have simplified and simplified my code, but the problem persists.
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); }
When I run my application, I get a RuntimeException and the following fingerprints in LogCat from my Log.e() statement:
LogCat message:
java.lang.IllegalArgumentException: column '_id' does not exist
So, back to SQLite 3 to find out what is different from my schema:
sqlite> .schema CREATE TABLE android_metadata (locale TEXT); CREATE TABLE circles (_id integer primary key auto-increment, sequence integer, radius real, x real, y real);
I donβt see how I am missing "_id".
What did I do wrong?
One thing that differs from my application and the notepad example is that I started by creating my application from scratch using the Eclipse Wizard while the sample application is already compiled. Is there any environmental changes that I need to make for a new application to use the SQLite database?