Android Cursor Read getPositionById(Cursor cursor, long theTargetId)

Here you can find the source of getPositionById(Cursor cursor, long theTargetId)

Description

get Position By Id

Declaration

public static int getPositionById(Cursor cursor, long theTargetId) 

Method Source Code

//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;
    }
}

Related

  1. getString(Cursor c, String column)
  2. getString(String column)
  3. getPhotoPathByLocalUri(Context context, Intent data)
  4. getIntFromCursor(Cursor cursor, String columnName)
  5. getStringFromCursor(Cursor cursor, String columnName)
  6. newClosedCursor()
  7. getDate(Cursor cursor, String columnName)