Android学习笔记之游标访问SQLite数据

在Android中,通过Cursor接口从SQLite数据库检索数据。Cursor存储查询结果的记录并提供多种访问方法。当不再使用时,需关闭Cursor,应用暂停或退出时会调用deactivate()。恢复时,通过requery()重新激活并获取最新数据。可以使用父Activity的startManagingCursor()进行管理。遍历记录使用moveToFirst()和moveToNext(),isAfterLast()用于检查是否超过最后一条记录。
摘要由CSDN通过智能技术生成

Retrieving data 检索数据

Retrieving data from SQLite databases in Android is done using Cursor. The Android SQLite query method returns a Cursor object containing the results of the query. To use Cursor android.database.Cursor must be imported.
在安卓中使用Cursor接口来从SQLite database 中检索数据。SQLite 查询返回的Cursor包含查询所得结果的Cursor对象。使用Cursor时应当导入android.databaseCursor包。

About Cursor 关于Cursor

Cursor store query result records in rows and grant many methods to access and iterate through the records. Cursor should be closed when no longer used, and will be deactivated with a call to Cursor.deactivate() when the application pauses or exists. On resume the Cursor.requery() statement is executed to re-enable the Cursor with fresh data. These functions can be managed by the parent Activity by calling startManagingCursor().
Cursor将查询结果记录存放在列中,并且提供了许多方法来访问和迭代这些记录。如果Cursor不再使用的时候应当关闭掉,并且当应用程序暂停或者滞留时应当调用Cursor.deactivate()来使Cursor失效。在应用程序继续运行时,Cursor.requery()用来重新启动数据更新之后的Cursor。这些函数由父Activity调用startManagingCursor()进行管理。

package higherpass.TestingData;

import java.util.Locale;

import android.app.Activity;
import android.os.Bundle;
import android.content.ContentValues;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值