Example of creating a database on Android using SQLite:
public class FeedReaderDbHelper extends SQLiteOpenHelper {
// If you change the database schema, you must increment the database version.
public static final int DATABASE_VERSION = 1;
public static final String DATABASE_NAME = "FeedReader.db";
public FeedReaderDbHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
public void onCreate(SQLiteDatabase db) {
db.execSQL(SQL_CREATE_ENTRIES);
}
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL(SQL_DELETE_ENTRIES);
}
}
Reference: link
In SQL_CREATE_ENTRIES
you inform the SQL DML commands for creating tables, fields, changing and removing fields.
The onCreate
method will be called when there is an interaction with the SQLite database and the database has not yet been created on the device.
The onUpgrade
method will be called when there is an interaction with the SQLite database, the database has already been created on the device, however the application on the device has been updated and the database is in another version.
You can put several% of one% of one underneath the other for the creation of a certain table, change a certain field, as you prefer.
There is also the possibility that Android communicates externally through WebServices with a server that presents a database, such as MySQL, PostgreSQL, MongoDB (NoSQL, document-oriented database) using Java, PHP, or another programming language to perform communication, the REST architecture is usually used and returns JSON to the application.
Other useful links:
link
link
link
link
link