January 2018
Intermediate to advanced
434 pages
14h 1m
English
Anko provides a wrapper around our built-in SQLite API, which helps eliminate a lot of boilerplate code and also adds safety mechanisms such as closing the database after the code execution is complete and more.
While implementing a SQLite database, the first step is to create the database helper class. In this case, we need the class to extend the ManagedSQLiteOpenHelper class instead of the SQLiteOpenHelper class, which we used to do. ManagedSQLiteOpenHelper is concurrency aware and closes the database at the end of query executions. Check out the following code for a simple database helper that I am using for this example:
class DatabaseHelper(ctx: Context) : ManagedSQLiteOpenHelper(ctx, "SupportDatabase", null, 1) { companion ...Read now
Unlock full access