Update database

by pramod.deore » Thu, 02 Dec 2010 19:24:33 GMT


Sponsored Links
 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?

-- 



Re: Update database

by Kumar Bibek » Thu, 02 Dec 2010 19:28:06 GMT


 What is the error??

Kumar Bibek
 http://techdroid.kbeanie.com 
 http://www.kbeanie.com 







-- 


Sponsored Links


Re: Update database

by Kostya Vasilyev » Thu, 02 Dec 2010 19:35:22 GMT


 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 --



Re: Update database

by pramod.deore » Fri, 03 Dec 2010 11:55:15 GMT


 Thanks Bibek and Kostya, problem is solved




-- 



Other Threads

1. ANdroid coding guidelines

Where Can I find the Android PDF to start my coding.I do not know JAVA
but I know C and C++ and linux internals.

Is it a must to learn JAVA and start coding.
I do not know XML as well..


Please give me a hint on how to start working on Android and recommend
some material or PDF to start working.

Thanks in Advance

Syed Sameer Ahmed
(Google FAN)

--~--~---------~--~----~------------~-------~--~----~

2. Xmpp demo!

Can someone put the demo XMPPSender or GtalkXMPP on the
web, or send me, because i can't download from nowhere..


                            Thanks a lot

--~--~---------~--~----~------------~-------~--~----~

3. Is it possible to tell OS that Activity behind a translucent activity no longer needs to be drawn?

4. check the manifest for intent-filters

5. ActivityGroup unable to restart Activity

6. Is there any RPC library available with Android

7. :Help needed