* What is?
SQLite is an Open Source Database. It requires limited memory (aprox. 250 kbyte).
SQLite is embeded in every Android device. Doesn't require a setup or administration.
* File system
Accessing database involves accesing the file system. This can be slow. It is recommended to perform
database operations asynchronously.
If an application creates a database, it is saved by default in /DATA/APP_NAME/databases/FILENAME.
DATA is the path which the Environment.getDataDirectory() method returns.
String s = Environment.getDataDirectory().toString();
Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show();
// return /data
* Open Helper
First you must create a subclass of the SQLiteOpenHelper, call the super() specifying the database and
version, override the two methods:
Both methods receive an SQLDatabase object as parameter.
It's a good practice to create a separte class for each table.
The database should use an identifier _id for his primary key. Several Android functions rely on this standard.
* SQLDatabas object
SQLDatabase object provides the insert(), update(), delete(), execSQL() methods.
The object ContentValues allows to define key/values.
Queries can be created via the rawQuery() and query(). The latter provides a structured interface for SQL query.
A query returns a cursor object which is the result of the query and points to one row of the result.
moveToFirst(), moveToNext(), isAfterLast(), getString(columnIndex)