使用数据库(DB) / 连接到数据库

import android.content.Context
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper

class DataBaseHelper(context: Context, dbName: String):
    SQLiteOpenHelper(context, dbName, null1) {

    override fun onCreate(db: SQLiteDatabase?) {}

    override fun onUpgrade(db: SQLiteDatabase?, oldVersion: Int,
                          newVersion: Int) {}
}

//Connect to the database
val dbHelper = DataBaseHelper(
    context,
    dbPath + "DatabaseName.sqlite"
)

//SQL query execution
val db = dbHelper.readableDatabase
val cursor = db.rawQuery(
    "SELECT * FROM country"null)

//Get the data
cursor.moveToFirst()
val countryName = cursor.getString(0)

println(countryName)

//Close the connection
cursor.close()