The SQLiteDatabase object depends on the type of operation on the database.
More information, visit the official website:
https://developer.android.com/training/basics/data-storage/databases.html#UpdateDbRow
It explains how to manipulate consultations on the SQLite database.
INSERT ROW
Gets the data repository in write mode
SQLiteDatabase db = mDbHelper.getWritableDatabase();
Create a new map of values, where column names are the keys
ContentValues values = new ContentValues();
values.put(FeedEntry.COLUMN_NAME_ENTRY_ID, id);
values.put(FeedEntry.COLUMN_NAME_TITLE, title);
values.put(FeedEntry.COLUMN_NAME_CONTENT, content);
Insert the new row, returning the primary key value of the new row
long newRowId;
newRowId = db.insert(
FeedEntry.TABLE_NAME,
FeedEntry.COLUMN_NAME_NULLABLE,
values);
UPDATE ROW
Define 'where' part of query.
String selection = FeedEntry.COLUMN_NAME_ENTRY_ID + " LIKE ?";
Specify arguments in placeholder order.
String[] selectionArgs = { String.valueOf(rowId) };
SQLiteDatabase db = mDbHelper.getReadableDatabase();
New value for one column
ContentValues values = new ContentValues();
values.put(FeedEntry.COLUMN_NAME_TITLE, title);
Which row to update, based on the ID
String selection = FeedEntry.COLUMN_NAME_ENTRY_ID + " LIKE ?";
String[] selectionArgs = { String.valueOf(rowId) };
int count = db.update(
FeedReaderDbHelper.FeedEntry.TABLE_NAME,
values,
selection,
selectionArgs);