tmoriarty wrote:
> This error only occurs when I return A cursor from the querry without
> _id in it.  The documentation for CursorAdapter says it needs _id to
> work properly.  If I understand this correctly it probably needs the
> primary key so it can commit changes to the Cursor back to the
> database.  However, I don't understand why they force the name to be
> _id.  I guess that is the root of my question.  If I am not
> understanding this correctly I would appreciate any insight.  Thanks.

Your analysis is probably correct. I was thinking I didn't use _id in my 
TourIt sample project, but it turns out I did. And, if you want a full 
read-write Cursor, you may not have a choice.

But, if you are merely looking to display the results of a query, I can 
think of two workarounds.

You could try renaming your existing primary key to _id in the results 
via appropriate SQL and rawQuery():

"SELECT MyKey AS _id, Other, Columns, Here FROM MyTable WHERE ..."

I haven't tried that, but I don't know how Android would know the 
difference between a "real" _id column and a renamed one.

Or, you could pour the results of your query into a List and use 
ArrayAdapter rather than SimpleCursorAdapter. This wouldn't be great for 
a large result set, of course.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
Warescription: All titles, revisions, & ebook formats, just $35/year

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to