3

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.

dif's user avatar
dif
2,5036 gold badges38 silver badges51 bronze badges
askedMar 6, 2012 at 3:17
JDeVas's user avatar
5
  • What exception/error are you seeing?CommentedMar 6, 2012 at 3:30
  • FYI, there's no such thing as anUPDATE query, there's a UPDATE statement. Am i the only one who gets mad at this? :\CommentedMar 6, 2012 at 4:57
  • Try thisUPDATE detail set done = 1 where vehicle='whatever';CommentedMar 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.CommentedMar 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.:)CommentedMar 6, 2012 at 16:11

1 Answer1

4
  //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);
answeredMar 6, 2012 at 3:54
Pradeep Sodhi's user avatar
Sign up to request clarification or add additional context in comments.

2 Comments

I think you meantdbx.update("details", cv1, "vehicle= ? ", null);
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.. :)

Your Answer

Sign up orlog in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to ourterms of service and acknowledge you have read ourprivacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.