This is a convention in the framework that the primary key be called "_id",
used by "simplified" adapter classes to make life easier for the developer.

--
Kostya Vasilyev -- http://kmansoft.wordpress.com
07.12.2010 1:33 пользователь "Ashish" <[email protected]> написал:
> Well as per my understanding.... it is of utmost importance to have
> _id column in android sqlite database.
> This is the default way of making each record unique in its nature...
> so, even if you don't use any primary key, ur records won't be
> duplicate.
>
>
> Regards,
> Ashish
>
> On Dec 3, 1:31 pm, "Jonas Petersson" <[email protected]> wrote:
>> On 12/03/2010 09:04 AM, pramod.deore wrote:
>>
>> > When I tried this as
>>  > [...]
>> >                    Cursor c = sampleDB.rawQuery("SELECT RoomID as _id
FROM "
>> > +ROOM_TABLE_NAME, null);
>>  > [...]
>> >                            new String[] {"RoomID"},
>>  > [...]
>> > java.lang.IllegalArgumentException: column 'RoomID' does not exist
>>
>> Yes, that is to be expected, you have just "renamed" the RoomID column
>> to "_id" so obviously you must also access it that way (or ALSO select
>> it under the original name, but that would be confusing IMHO).
>>
>>                         / Jonas
>>
>> > On Dec 3, 12:51 pm, "Jonas Petersson"<[email protected]>  wrote:
>> >> Um, you might try something like "select RoomID as _id ..."
>>
>> >>                          Best / Jonas
>>
>> >> On 12/03/2010 08:40 AM, Kumar Bibek wrote:
>>
>> >>> You cannot in this case. This is a mandatory requirement.
>>
>> >>> "pramod.deore"<[email protected]>    wrote:
>>
>> >>>> Hi Bibek, Thanks for reply. But my table RoomTable have only three
>> >>>> columns, RoomID, RoomName, and RoomSuffix. It doesn't have  _id
field.
>> >>>> Then how to use Cursor Adapter here.
>>
>> >>>> On Dec 3, 11:55 am, Kumar Bibek<[email protected]>    wrote:
>> >>>>> Cursor Adapters require the table to have a _id field. Else, you
would get
>> >>>>> this exception.
>> >>>>> Kumar Bibekhttp://techdroid.kbeanie.comhttp://www.kbeanie.com
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to