Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8786927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:45:27+00:00 2026-06-13T21:45:27+00:00

I want to execute a statement such as UPDATE myTable SET myField = myField

  • 0

I want to execute a statement such as

UPDATE myTable SET myField = myField + 1

in an Android SQLite database. (Yes, I want to increment myField for all records.)

My first idea was to use execSQL, but the documentation says:

execute a single SQL statement that is NOT a SELECT/INSERT/UPDATE/DELETE.

…

For UPDATE statements, use any of the following instead.
• update(String, ContentValues, String, String[])
• updateWithOnConflict(String, ContentValues, String, String[], int)

However, as far as I can see, this type of UPDATE cannot be done with the SQLiteDatabase.update method. Did I miss some clever trick to do this with SQLiteDatabase.update or is the documentation broken? (Running the above SQL with execSQL works fine, although the documentation claims otherwise.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T21:45:28+00:00Added an answer on June 13, 2026 at 9:45 pm

    That method is just fine. It has to be, because the underlying C API does not distinguish those. Any statement that does not return value can be executed with execSQL.

    The update* and insert* are legitimate helper methods, but the documentation would really do better if it didn’t claim they must be used for all inserts/updates since they simply can’t be (ever used insert into table select ...? I do that all the time!)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to execute simple statement: SELECT * FROM OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Text;Database=C:\Temp\;','SELECT * FROM [test.csv]') And
Set rs = conn.Execute(Statement) //rs has 6 fields I want to add the current
I execute an INSERT INTO statement cursor.execute(INSERT INTO mytable(height) VALUES(%s),(height)) and I want to
i have such procedure but all the time i want to execute it i
I want to execute one mysql statement where I have a select that is
I want to add only unique records into a database table. Is there any
I want to execute select statement within CTE based on a codition. something like
I want to execute multiple, separate SQL statements like in the JDBC cookbook: Statement
I want to execute a dynamic SQL statement, with its returned value being the
Is it possible to execute a statement such as m.invoke(param1 ,param2) in a new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.