Thursday, December 2, 2010

[android-developers] Re: Update database

Thanks Bibek and Kostya, problem is solved

On Dec 2, 4:35 pm, Kostya Vasilyev <kmans...@gmail.com> wrote:
> The next-to-last argument to db.update is the WHERE clause, but without
> the WHERE (look it up in a SQL reference).
>
> So while in SQL you'd write "WHERE SwitchName = value", with db.update
> you need to use "SwitchName = value".
>
> The last argument is used supply variable values to the conditions. This
> is more efficient as well as safer. Each value in the last argument
> (which is an array) replaces one "?" placeholder in the condition.
>
> The entire statement might look like this:
>
> sampleDB.update(SWITCH_TABLE_NAME, args, "SwitchName = ?", new String[]
> { oldSwitchName} );
>
> -- Kostya
>
> 02.12.2010 14:24, pramod.deore пишет:
>
>
>
> > Hi, I have a table with 5 columns.
> > 1. RoomID
> > 2. RoomName
> > 3.RoomSuffix
> > 4. SwitchID
> > 5. SwitchName
>
> > I have some data in this table. Now I want to update database. How to
> > do this? I search for this but didn't get well answer
>
> > I had tried it like:
>
> > sampleDB =  this.openOrCreateDatabase(SAMPLE_DBNAME, MODE_PRIVATE,
> > null);
>
> >                    ContentValues args = new ContentValues();
> >                    args.put(SwitchName, switchRename);
>
> > Here I want to put SwitchName value as switchRename.
> > Now I execute method as:
>
> > sampleDB.update(SWITCH_TABLE_NAME, args, SwitchName
> > +'menuItemName',null);
>
> > But here second last argument (i.e where clause give me an error).In
> > where clause I want as "SwitchName = 'xyz' "  i.e where SwitchName is
> > xyz. How to write this where condition correctly?
>
> --
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment