If a record (row) already exists, you need to perform an update, not insert.

Before:

roomid: 1001
roomname: Scheherezade's bedroom
switchid, switchname: null

Update:

UPDATE tablename
SET switchid = 512, switchname = 'blahblah'
WHERE roomid = 1001

After:

roomid: 1001
roomname: Scheherezade's bedroom
switchid: 512
switchname: blahblah

You can use SQLiteDatbase.update for this:

http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#update(java.lang.String, android.content.ContentValues, java.lang.String, java.lang.String[])

-- Kostya

12.11.2010 13:21, pramod.deore пишет:
Hi all,

          I have a table which has four columns (roomid primary key,
roomaname, switchid, and switchname). Now if I tried to insert a
record in this table then if roomid is not exist in the table then
record is added successfully. (And it is obvious ).

         But what I want is if suppose primary key is exist already and
I tried to insert the record then last two columns values (i.e
switchid and switchname) is added to that record.

         I think it is not possible. But still want to take experts
opinion.

Thanks



--
Kostya Vasilyev -- WiFi Manager + pretty widget -- 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

Reply via email to