Android Cursor 使用细节

这篇博客重新探讨了Android中SQLite数据库的操作,尤其是Cursor的使用。内容包括Cursor作为数据库查询结果的数据源,以及在多线程环境中需要注意的同步问题。通过对Cursor的深入理解和实践,有助于更好地进行数据库查询和数据管理。
摘要由CSDN通过智能技术生成

前言

最近接收一个新的ReactNative项目,里面有有关日历的操作需要了解数据库的知识,以前使用封装好的工具比较多,对具体的SQLite的操作已经不熟悉了,再次再归纳整理下相关知识。

基础脑图

Android Cursor简洁脑图

知识点

  1. 是数据库查询的随机数据源,在使用时需要注意多线程同步问题。
/**
    * This interface provides random read-write access to the result set returned by a database query.
    * Cursor implementations are not required to be synchronized so code using a Cursor from multiple threads should perform its own synchronization when using the Cursor.
    * Implementations should subclass {@link AbstractCursor}.
*/
  1. 获取数据
    fun obtainCursorData(cursor: Cursor) {
        val cursorRowCount = cursor.count
        if (cursorRowCount == 0) {
            // cursor中没有数据
        }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值