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. Ads in apps... How to successfully generate a larger revenue?

There is AdWhirl that will allow you to serve up from different providers.
I have not tried it yet but since I have both admob, which was doing very
well for me, and Mobclix I may try to do them both.  I found it interesting
that while keeping the ad rotation interval the same between the two I was
serving around 30K impression with mobclix and about 17K with admob.
My CTR on admob was significantly higher.  Now that I switched back to admob
I found a "glitch" that I had not noticed before and wonder if my mobclix
CTR could have been better.    Its actually encouraging to know that at
least some money is being made out there.   I racked up 48 bucks for the
last week in january and have about twice as many users now so I'm waiting
to see if my glitch has been fixed.   Now another topic that would fun to
discuss is how the heck do you get users to update?!






> 

2. Langkah-langkah MengRoot

Suhu-suhu di Komunitas andrid????

Saya mau petunjuknya nih langkah-langkah mengroot HTC Hero saya???

Cara memasukan NeoRom hasil downloadtan???

 

Dan klo suhu2 punya info toko yang menjual asesories Android(Leateher Case,
Silicone DLL) di daerah Jabodetabek.... Tolong infokan ke saya yaa.....

 

Terimakasih Banyak...atas atensinya...dan semoga ada jawaban yang memuaskan
saya

 

Arisandy_..

-- 
"Indonesian Android Community [id-android]" 

3. hangup outgoing call programmatically - is this even possible?

4. Rootcertificates

5. running an online streaming Media player in background as a service .

6. Is this a joke or a spam or another April 1st prank?

7. ALSA: Waiting for sevice media.audio_policy...