When I write a ContentProvider that querying the Sqlite. I using the simple code as bellow. I get this weird the column doesn't not exist error. what make me confusing that the DBHelper has been worked well for a time.
@Override |
Also I defined the _ID column.
Code Of DBHelper |
@Override paramSQLiteDatabase.execSQL(sql); |
How to fix it?
1. Make sure the you have a Column of _id, the column name here is case sensitive. the internal logic use “_id” as a key query to the dictionary.
2. Since the DBCreation Logic once be invoked Once. So either Remove the DB file manually which is located in /data/data/yourappnamespace/databases
or just rename the table name in your sql to reflect the changes. otherwise, you keep polling the Prevous defined DB even you changed your code.
3 comments:
Thanks!
This post was very useful; I was calling it "Id". I didn't realize there was a naming standard you had to follow.
I was passing the Cursor to a CursorAdapter and it didn't like that I didn't have a _id column.
glad it helps:)
Post a Comment