Sqlite

Sqlite 数据库接口,提供原生 SQL 语句的执行与查询功能。

该接口封装了对 SQLite 数据库的操作,允许执行非查询语句(如 CREATE, INSERT, UPDATE, DELETE) 以及查询语句(SELECT),并将查询结果以易于处理的集合形式返回。 同时支持简单的事务管理与数据库连接关闭操作。

Author

M8Test, [email protected], https://m8test.com

Functions

Link copied to clipboard
abstract fun beginTransaction()

开启一个事务。

Link copied to clipboard
abstract override fun close()

关闭当前对象, 如果没有调用本方法则会报错, 当然本方法由系统调用, 不需要手动调用.

Link copied to clipboard
abstract fun createTable(tableName: String, columns: Map<String, String>): Boolean

创建数据表。

Link copied to clipboard
abstract fun delete(table: String, whereClause: String?, whereArgs: Array<String>?): Int

删除数据。

Link copied to clipboard
abstract fun dropTable(tableName: String): Boolean

删除数据表。

Link copied to clipboard
abstract fun endTransaction()

结束当前事务。

Link copied to clipboard
abstract fun execSQL(sql: String, bindArgs: Array<Any?>?): Boolean

执行一条非查询的 SQL 语句。

Link copied to clipboard
abstract fun getContext(): ScriptContext

获取脚本上下文对象 ScriptContext.

Link copied to clipboard
abstract fun hasTable(tableName: String): Boolean

判断指定表是否存在。

Link copied to clipboard
abstract fun insert(table: String, nullColumnHack: String?, values: Map<String, Any?>?): Long

插入一条数据。

Link copied to clipboard
abstract fun isClosed(): Boolean

判断当前对象是否已经调用了 close 方法.

Link copied to clipboard
abstract fun isOpen(): Boolean

判断数据库是否处于打开状态。

Link copied to clipboard
abstract fun query(sql: String, bindArgs: Array<String>?): List<Map<String, String?>>

执行一条查询 SQL 语句,并返回结果集。

Link copied to clipboard

标记当前事务为成功。

Link copied to clipboard
abstract fun update(table: String, values: Map<String, Any?>, whereClause: String?, whereArgs: Array<String>?): Int

更新数据。