0

The statement is the following:

UPDATE mytable SET displayed_value=(close_time_2 || '-' || open_time_2)
WHERE close_time_2 != ""

Now I call it with mDb.execSQL. How to execute the same with mDb.update? (need to see how many records were updated)

Update: just to give an example. Here is my database before update:

item  close_time_2  open_time_2  displayed_value
1     02:40         04:50
2     02:15         02:45
3                   05:15

here is what I should get after update

item  close_time_2  open_time_2  displayed_value
1     02:40         04:50        02:40-04:50
2     02:15         02:45        02:15-02:45
3                   05:15
Juan Mellado
  • 14,973
  • 5
  • 47
  • 54
LA_
  • 19,823
  • 58
  • 172
  • 308

1 Answers1

0

It's really not that hard to find out how to use the update-method. See the Docs and this Sample-code.

Lukas Knuth
  • 25,449
  • 15
  • 83
  • 111
  • could you please point me to the code, which creates ContentValues in such a way, that field value is equal to another field value? I need to copy data from field1 (close_time_2) and field2 (open_time_2) to field3 (displayed_value). – LA_ May 22 '11 at 15:56
  • I'm nor sure what you mean by that. Is this still a question about the `update`-method? – Lukas Knuth May 22 '11 at 16:27
  • Yes, the question is about update method. I've updated the question text - please see it again. – LA_ May 22 '11 at 16:32
  • Where's the problem? Select both columns first, then update the `displayed_value`-value. But I don't understand why you have this column in the first place. If you want this simple string to be shown by your App, why don't you query both columns and add them together to one String? – Lukas Knuth May 22 '11 at 17:12