Example usage for android.database Cursor getColumnIndex

List of usage examples for android.database Cursor getColumnIndex

Introduction

In this page you can find the example usage for android.database Cursor getColumnIndex.

Prototype

int getColumnIndex(String columnName);

Source Link

Document

Returns the zero-based index for the given column name, or -1 if the column doesn't exist.

Usage

From source file:Main.java

public static int getPhoneIndex(Cursor dataCursor) {
    return dataCursor.getColumnIndex(Phone.NUMBER);
}

From source file:Main.java

public static int getMimeIndex(Cursor dataCursor) {
    return dataCursor.getColumnIndex(Data.MIMETYPE);
}

From source file:Main.java

public static int getEmailIndex(Cursor dataCursor) {
    return dataCursor.getColumnIndex(Email.ADDRESS);
}

From source file:Main.java

/**
 * Get the Contacts.PHOTO_THUMBNAIL_URI index for ContactPicker.
 *///from  w  w w. jav  a 2 s. c om
public static int getThumbnailIndex(Cursor contactCursor) {
    return contactCursor.getColumnIndex(ContactsContract.Contacts.PHOTO_THUMBNAIL_URI);
}

From source file:Main.java

/**
 * Get the Contacts.PHOTO_URI index for ContactPicker.
 */// w ww  . j  a v a 2s  .  co  m
public static int getPhotoIndex(Cursor contactCursor) {
    return contactCursor.getColumnIndex(ContactsContract.Contacts.PHOTO_URI);
}

From source file:Main.java

/**
 * Get the Data.CONTACT_ID index for PhoneNumberPicker.
 *//*from w  w w. j a  v  a2s. c o m*/
public static int getContactIdIndex(Cursor contactCursor) {
    return contactCursor.getColumnIndex(Data.CONTACT_ID);
}

From source file:Main.java

/**
 * Get the Contacts.DISPLAY_NAME index for ContactPicker.
 *///from ww w .  j a v a2 s  . c o  m
public static int getNameIndex(Cursor contactCursor) {
    return contactCursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME);
}

From source file:Main.java

/**
 * Get the Contacts._ID index for ContactPicker.
 *//* w w w . j  ava  2 s  .c om*/
public static int getIdIndex(Cursor contactCursor) {
    return contactCursor.getColumnIndex(ContactsContract.Contacts._ID);
}

From source file:Main.java

public static int intFromCursor(Cursor c, String field) {
    if (c.isNull(c.getColumnIndex(field))) {
        return -1;
    }// ww w . j a  v a 2s  . c om
    return c.getInt(c.getColumnIndex(field));
}

From source file:Main.java

public static String stringFromCursor(Cursor c, String field) {
    if (c.isNull(c.getColumnIndex(field))) {
        return null;
    }//  w  ww.j a va2  s. co m
    return c.getString(c.getColumnIndex(field));
}