Kotlin SQLite example - CRUD operations with ListView | Android
https://grokonez.com/android/kotlin-sqlite-example-crud-operations-with-listview-android
SQLite is an Open Source database that supports standard relational database features like SQL syntax, transactions and prepared statements. Each column in an SQLite database is assigned one of data types: NULL
, INTEGER
, REAL
, TEXT
, BLOB
. In this tutorial, we're gonna look at how to make SQLite CRUD operations when interacting with ListView
.
Related Posts:
More Practice: Kotlin SQLite example – Search with Listview | Android
I. Technologies
- Android Studio 3
- Kotlin 1.1.51
II. Overview
1. Goal
We will build an Android App that supports showing, inserting, editing, deleting Notes from/to SQLite Database withListView
:
2. SQLite
2.1 SQLiteDatabase
SQLiteDatabase
is the base class for working with a SQLite Database in Android. It provides:
-
insert()
,update()
,delete()
method -
execSQL()
to execute an SQL statement directly
To work with SQLite Database, we create a subclass of SQLiteOpenHelper
class:
- constructor: call
super()
method to specify database_name, version and context - override
onCreate()
to execute CREATE TABLE command - override
onUpgrade()
to handle database version increment - indicate read/write mode by using
getReadableDatabase()
orgetWritableDatabase()
method
More at:
https://grokonez.com/android/kotlin-sqlite-example-crud-operations-with-listview-android
Top comments (0)