Skip to content
Advertisement

Cursor should only select cells with a different value

I want, that my cursor is moving to the next cell with different content and I want the cursor to skip over all cells that have a value that already existed.

For example we have the column: Beer, Car, Car, House, Beer, Tree (in KEY_AREA)

The cursor should select: Beer, Car, House, Tree and skip 1 Car and 1 Beer.

JavaScript

Advertisement

Answer

Since you are interested only in the column DBHelper.KEY_AREA you can use the overload of query() which has as its first argument a boolean value indicating whether you want distinct results or not.

In your case you should pass true:

JavaScript

Also, you don’t need cursor.getColumnIndexOrThrow(DBHelper.KEY_AREA) to get the column’s index.
Your query returns only 1 column and you can safely use 0 as its index:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement