---
title: "What is cursor in android?"  
description: "What is cursor in android?"  
author: "Prateek sharma"  
published: 2018-04-06  
canonical: https://answers.mindstick.com/qa/40995/what-is-cursor-in-android  
category: "android"  
tags: ["android"]  
reading_time: 1 minute  

---

# What is cursor in android?

## Answers

### Answer by Arti Mishra

**[Cursor](https://www.mindstick.com/articles/23407/cursor-and-trigger-in-sql-server) In [Android](https://www.mindstick.com/articles/1672/android-internals)**Cursors is a class that are used to **store result set of a query** which made [against](https://www.mindstick.com/news/2526/resolution-against-anti-satellite-tests-adopted-by-un-to-reduce-space-debris) [database](https://www.mindstick.com/articles/100/windows-service-to-update-record-from-one-database-to-another-after-certain-interval-of-time) in android. Cursor class **contain powerful API** that allows an [application](https://www.mindstick.com/blog/59/xaml-extensible-application-markup-language) to read the columns and returned the [query string](https://www.mindstick.com/articles/512/query-string-in-asp-dot-net). When using the cursor then [multiple](https://www.mindstick.com/forum/2323/handling-multiple-submit-button-in-asp-dot-net-mvc) [threads](https://www.mindstick.com/blog/11678/threads-in-java) are perform its own synchronization. By using cursor we can **save lot of ram and memory**.\
**The cursor is defined in the following ways:**

```
Public cursor cursorFunction()
{
Cursor cursor = sqLiteDatabase.query( tableName, tableColumns, whereClause, whereArgs, groupBy, having, orderBy);
Return cursor;
}
```

\
For creating cursor, we can pass different arguments like tableName, columnName ,whereCluse, groupBy, Having, orderBy etc after that we receive the cursor. In order to get the no. of columns and rows data, then we use following code-

```
Int totalColumn=cursor.getColumnCount();
Int totalRow=cursor.getCount();
```

**For finding the [column name](https://www.mindstick.com/forum/369/how-can-i-add-a-column-name-to-my-grid), we use following code.**

```
String[] columnName = cursor.getColumnNames();
```

The cursor are used to points a single row at a time and any query in [SQLite](https://www.mindstick.com/articles/1554/crud-operation-in-asp-dot-net-using-sqlite-database) database returns a cursor object. \


---

Original Source: https://answers.mindstick.com/qa/40995/what-is-cursor-in-android

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
