SQLite
SQLite is a relational database management system (RDBMS). If most RDBMSs such as MySQL, Oracle, etc. are standalone server processes, then SQLite is embedded because it is provided in the form of a library that is linked in applications.
Like other RDBMSs, data is accessed in a SQLite database by using Structured Query Language (SQL).
Android SQLite Java Classes
Cursor: a class provides access to the results of a database query. Its methods include:
- close(): release all resources used by cursor and close it.
- getCount(): returns the number of rows contained within the result set.
- moveToFirst(): moves to the first row in the result set.
- moveToLast(): moves to the last row in the result set.
- moveToNext(): moves to the next row in the result set.
- move(): moves by a specified offset from the current position in the result set.
- get<type>() (such as getInt(), getDouble(), so on): returns the value of the specified <type> contained at the specified column index of the row at the current cursor position.
SQLiteDatabase provides the primary interface between the application code and underlying SQLite database. Its methods include:
- insert(): inserts a new row into a database table.
- delete(): deletes rows from a database table
- query(): performs a specified database query and returns matching results via a Cursor object.
- execSQL(): executes a single SQL Statement that does not return result data.
- rawQuery(): executes an SQL query statement and returns matching results in the form of a Cursor object.
SQLiteOpenHelper is designed to make it easier to create and update databases. Its methods include:
- onCreate(): called when the database is created for the first time.
- onUpgrade(): called in the event that the application code contains a more recent database version number reference.
- onOpen(): called when the database is opened.
- getWritableDatabase(): opens or creates a database for reading and writing.
- getReadableDatabase(): creates or opens a database for reading only.
- close(): closes the database.
ContentValues allows key/value pairs to be declared consisting of table column identifiers and the values to be stored in each column. Its methods include:
- put(): adds a value to the set.
No comments:
Post a Comment