Return the long stored in the specified column of the cursor, -1 if column does not exist - Android Database

Android examples for Database:Cursor Column

Description

Return the long stored in the specified column of the cursor, -1 if column does not exist

Demo Code


import java.io.Closeable;
import java.io.IOException;
import android.database.Cursor;

public class Main{
    /** Return the long stored in the specified column of the cursor, -1 if column does not exist */
    public static long getLong(Cursor cursor, DatabaseColumn column) {
        int index = cursor.getColumnIndex(column.getName());
        return (index != -1) ? cursor.getLong(index) : index;
    }//  ww  w.j  a  v  a 2s . co  m
}

Related Tutorials