Hi,
I recently ran into a situation querying a database table that I found
odd.  My table had the following fields. (_id (PRIMARY KEY), path,
title, artist, album, genre).  I was writting a querry that would
reurn all of the distict aritists, albums, or genres to an activity
for display to a ListView.  I was using the query method which returns
a Cursor.  I found that I had to include _id in the Cursor or it would
error out once the Cursor was used in a CursorAdapter.  This forced me
to write a slightly more copmplex querry using a GROUP BY and
uitilizing the MAX() function to return an _id that I didn't really
want.  I believe I understand the reason why primary key must be
present, so you can uniqyuly identify a row in the Cursor to allow you
to make changes to the undelying database through the Cursor.
However, why force a hard coded _id.  This seems to be enforcing a
naming question on the primary key. This doesn't seem like good
practice.  Can anyone shed some light onto why this is designed this
way, and what approach people usually take when they want data in a
Cursor for  ListView display and are unconcerned with the primary key
or changing the database in anyway through the Cursor.  Thanks.
Tom
--~--~---------~--~----~------------~-------~--~----~
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