I assigned pre-defined  value for foregin key. The thing that happens is
that on first time use of that key, an entry is created in database. But if
I use that value for second time then value is not updated in database

 My database table strings are as follows


    private static final String DATABASE_PROFILE=
        "create table profile (_id integer primary key autoincrement, "
        + "pro_name TEXT not null,"
        + "password TEXT not null"
        + ");";

    private static final String DATABASE_EVENT =
        "create table event"
     + "(_id integer primary key autoincrement, "
     + "pro_id INTEGER, "
     + "title TEXT not null, "
        + "priority TEXT not null,"
        + "priority_pos INTEGER not null,"
        + "status TEXT not null,"
        + "status_pos INTEGER not null,"
                + "from_date TEXT not null,"
                + "from_time TEXT not null,"
                + "FOREIGN KEY(pro_id) REFERENCES profile(_id)  "
                +");";



2011/3/14 Kostya Vasilyev <[email protected]>

>  Most likely, it means you didn't specify a value for the foreign key when
> inserting into the child table (ref_id_value in the snippet below).
>
> -- Kostya
>
> 14.03.2011 16:27, Brad Stintson пишет:
>
> Thanks.
>
>  I created foreign key, but when I try to insert values using m
> application it throws
> *android.database.sqlite.SQLiteConstraintException: error code*
>  * 19: constraint failed.*
> *
> *
> But if I insert values manually usiing console, then values are inserted
> properly. Why is it so?
>
>
>  2011/3/13 Kostya Vasilyev <[email protected]>
>
>>  SQLite has foreign key support starting with version 3.6.19.
>>
>> http://www.sqlite.org/foreignkeys.html
>>
>> Some versions of Android have SQLite versions earlier than that - someone
>> posted a breakdown recently, check the list archives.
>>
>> For earlier versions, it works pretty well to do something like:
>>
>> CREATE TABLE ....
>> .....
>>         ref_id_value INTEGER NOT NULL REFERENCES the_other_table (_id)
>>
>>
>> For transactions, check SQLiteDatabase docs:
>>
>>
>> http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#beginTransaction()
>>
>> The above gives the usual pattern for using transactions.
>>
>> -- Kostya
>>
>> 13.03.2011 13:16, Brad Stintson пишет:
>>
>> How to use transaction and how to implement the concept of foreign key?
>>
>> 2011/3/13 Kostya Vasilyev <[email protected]>
>>
>>> Multiple inserts, one at a time. Preferably using a transaction.
>>> 13.03.2011 12:58 пользователь "Brad Stintson" <[email protected]>
>>> написал:
>>>
>>> > How to insert multiple tables which have few fields in common?
>>> >
>>>  > --
>>> > 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
>>>  --
>>> 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
>>
>>
>> --
>> 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
>>
>>
>>
>>   --
>> Kostya Vasilyev -- http://kmansoft.wordpress.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]
>> 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
>
>
>
> --
> Kostya Vasilyev -- http://kmansoft.wordpress.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]
> 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