Android – SQLite update

If you haven’t created yet SQLite helper class that extends SQLiteOpenHelper read this post.

To update an existing record/row in SQLite table you need:

  • table name
  • column names that will be updates
  • the new column values
  • selection criteria

I will first create a method that has 3 parameters, SQLiteDatabase, an id and an object that has all the values to be updated:

SQLite update record/row, <span>Android – SQLite update</span>, KandZ

Next, I will use ContentValues class to store a set of values so later used with update:

SQLite update record/row, <span>Android – SQLite update</span>, KandZ

Now create one string for the selection and one string array for the selection arguments. Read this post for more information.

SQLite update record/row, <span>Android – SQLite update</span>, KandZ

Now use the update command:

SQLite update record/row, <span>Android – SQLite update</span>, KandZ

THE END!!!

99020cookie-checkAndroid – SQLite updateAndroid – SQLite update

Related posts