sqlite - Android: column '_id' does not exist -
i getting error
illegalargumentexception: column '_id' not exist
when using simplecursoradapter
retrieve database, , table indeed have _id
column. noticing common problem, have tried work around given of solutions online none of them work. cursor query:
simplecursoradapter madapter = new simplecursoradapter(this, r.layout.quoterow, mycursor, new string[]{"_id", "quote"}, new int[]{r.id.quote});
although should mention original did not include _id
column, added try , solve problem. has got ideas might solve problem?
your database doesn't have have column called '_id' simplecursoradaptor need have 1 returned. can alias.
an example have table columns...
uid,name,number
to query simplecursoradapter, database rawquery
...
select uid _id,name,number my_table
this works fine , supplies necessary '_id' column simplecursoradapter.
edit: far understand _id field used unique key make sure data cursor handles can handled correctly adapters , adapterviews etc.
look @ data model in docs content providers.
using unique key in 'databases' of whatever kind pretty universal practice, , far can tell, use of column name '_id' (or '_id') way of standardizing , simplifying things across databases, content providers, cursors, adapters etc etc
in short, in order these various components work correctly, need data column unique values must 'know' name of column is. wouldn't 'know', speak, column name 'uid' 1 need opposed 'name' , 'number' columns.
Comments
Post a Comment