在android中使用cursor [英] use of cursor in android

查看:165
本文介绍了在android中使用cursor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在浏览互联网上的一些关于数据库连接,检索的代码。我看到光标CUR1 = moveToFirst()在许多代码,我想知道有什么用光标,为什么我们使用 moveToFirst(),因为我是新来的Android系统。

I was going through some of the codes in the internet regarding the database connection, retrieval. I saw Cursor cur1= moveToFirst() in many codes,i wanted to know what is the use of cursor and why we use moveToFirst() as i am new to android.

推荐答案

光标是接口代表任何数据库的二维表。当您尝试使用 SELECT 语句检索某些数据时,数据库将首先创建一个 CURSOR 对象,并将其引用返回给您。

Cursor is the Interface which represents a 2 dimensional table of any database. When you try to retrieve some data using SELECT statement, then the database will first create a CURSOR object and return its reference to you.

此返回引用的指针指向第0个位置,否则在第一个位置之前称为 游标,因此当您想从游标中取出数据时,必须先移至第一条记录,因此我们必须使用 moveToFirst

The pointer of this returned reference is pointing to the 0th location which is otherwise called as before first location of the Cursor, so when you want to retrive data from the cursor, you have to first move to the first record so we have to use moveToFirst

在调用 moveToFirst()光标方式,它需要将光标指向第一位置即可。现在,您可以访问第一条记录

When you invokes moveToFirst() method on the Cursor, it takes the cursor pointer to the first location. Now you can access the data present in the first record

这篇关于在android中使用cursor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆