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 using myDB.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.

5
  • What exception/error are you seeing? Commented Mar 6, 2012 at 3:30
  • FYI, there's no such thing as an UPDATE query, there's a UPDATE statement. Am i the only one who gets mad at this? :\ Commented Mar 6, 2012 at 4:57
  • Try this UPDATE detail set done = 1 where vehicle='whatever'; Commented Mar 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. Commented Mar 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.:) Commented Mar 6, 2012 at 16:11

1 Answer 1

4
  //Declaration  
SQLiteDatabase dbx;
ContentValues cv1;
EventDataSQLHelper eventsData;//object of class in which table is created


//on create
eventsData = new EventDataSQLHelper(this);
dbx= eventsData.getReadableDatabase();
 cv1 = new ContentValues();

cv1.put("done",1);


//update query
dbx.update("details", cv1, "vehicle=" ? , null);
Sign up to request clarification or add additional context in comments.

2 Comments

I think you meant dbx.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

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy 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.