How to grab the value stored in a column using Cursor?

Asked

Viewed 364 times

1

I have a cursor that receives all data from my table then use the Simplescursoradapter to put in a listview.

I was wondering if with this same cursor I could take a die from a Row and put in a textview.

1 answer

1


For each type of data a table column stores the interface implementation Cursor provides a method to obtain its value.

To get the value stored in a string type column you must use the method getString(int column).

These methods use an integer(index) to identify the column.

It is possible to get this index through the column name using the method getColumnIndexOrThrow(String columnName).

Thus, to get the value stored in a column of the string name type XXX you must use:

String valor = cursor.getString(cursor.getColumnIndexOrThrow("XXX"));

Browser other questions tagged

You are not signed in. Login or sign up in order to post.