Here you can find the source of getPositionById(Cursor cursor, long theTargetId)
public static int getPositionById(Cursor cursor, long theTargetId)
//package com.java2s; import android.database.Cursor; public class Main { public static int getPositionById(Cursor cursor, long theTargetId) { int theWantedPosition = -1; if (cursor != null && theTargetId > 0) { if (cursor.moveToFirst()) { while (!cursor.isAfterLast()) { if (cursor.getLong(0) == theTargetId) { theWantedPosition = cursor.getPosition(); break; }/* ww w.j av a 2 s .c o m*/ cursor.moveToNext(); } } } return theWantedPosition; } }