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

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

问题描述

我会通过一些有关数据库连接,检索codeS的网络连接。我看到光标CUR1 = moveToFirst()在许多codeS,我想知道有什么用游标的,为什么我们使用 moveToFirst( ),因为我是新来的机器人。

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.

推荐答案

光标是重新$ P $类psents任何数据库的二维表。当您尝试使用检索一些数据的选择语句,则数据库会首先创建一个 CURSOR 对象,并返回其引用到你。

Cursor is the class 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号位置这是之前第一个位置,否则所谓的光标作为 ,所以当要从光标retrive数据,你必须先移动到第一条记录,所以我们要使用 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()光标方式,它需要将光标指向第一位置。现在,您可以访问数据present在第一条记录

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中使用游标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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