I am trying to update a single column in a SQLite database table in my Android project. What I want to do is set the value of "done" column to 1, when the vehicle number is same. I preferred to go with sql queries other than usingmyDB.update. So I used this query,
update 'details' set done = 1 where vehicle=="*****"But the problem is, this query is working perfectly in the sqlite databse browser, not in android simulator. This is completely not working at the android simulator. Hope ur advice. Thanks in advance.
- What exception/error are you seeing?Mike Bockus– Mike Bockus2012-03-06 03:30:24 +00:00CommentedMar 6, 2012 at 3:30
- FYI, there's no such thing as an
UPDATEquery, there's a UPDATE statement. Am i the only one who gets mad at this? :\st0le– st0le2012-03-06 04:57:39 +00:00CommentedMar 6, 2012 at 4:57 - Try this
UPDATE detail set done = 1 where vehicle='whatever';st0le– st0le2012-03-06 04:58:09 +00:00CommentedMar 6, 2012 at 4:58 - if you want to give query from android then its case sensitive so make sure that whatever field your are using its used proper cases. If capital then it should be capital. If its small then it should be small.Jwalin Shah– Jwalin Shah2012-03-06 05:33:44 +00:00CommentedMar 6, 2012 at 5:33
- I didn't received any exceptions or error. After executing the statement I didn't sense any change in that done column. It only changed when I executed the same query(or Statement, whatever) in the sqlite database browser. That is what happened. Also I used the semi colon(;). Problem is not with that semi colon. Any way I shifted to the myDB.update method. Thank you for ur concern.:)JDeVas– JDeVas2012-03-06 16:11:29 +00:00CommentedMar 6, 2012 at 16:11
1 Answer1
//Declaration SQLiteDatabase dbx;ContentValues cv1;EventDataSQLHelper eventsData;//object of class in which table is created//on createeventsData = new EventDataSQLHelper(this);dbx= eventsData.getReadableDatabase(); cv1 = new ContentValues();cv1.put("done",1);//update querydbx.update("details", cv1, "vehicle=" ? , null); Sign up to request clarification or add additional context in comments.
2 Comments
st0le
I think you meant
dbx.update("details", cv1, "vehicle= ? ", null);JDeVas
Thank you for your reply. What I need is the use of sql update statement. Not the dbx.update method calling. But I couldn't figured out the reason for the failure of my statement. So I shifted into your solution. Thanks.. :)
Explore related questions
See similar questions with these tags.

