Example usage for android.database.sqlite SQLiteCursor getColumnIndex

List of usage examples for android.database.sqlite SQLiteCursor getColumnIndex

Introduction

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

Prototype

@Override
    public int getColumnIndex(String columnName) 

Source Link

Usage

From source file:android.support.v7.testutils.TestUtilsMatchers.java

/**
 * Returns a matcher that matches data entry in <code>SQLiteCursor</code> that has
 * the specified text in the specified column.
 *///from  ww w  . j  a  v a 2  s .  co m
public static Matcher<Object> withCursorItemContent(final String columnName, final String expectedText) {
    return new BoundedMatcher<Object, SQLiteCursor>(SQLiteCursor.class) {
        @Override
        public void describeTo(Description description) {
            description.appendText("doesn't match " + expectedText);
        }

        @Override
        protected boolean matchesSafely(SQLiteCursor cursor) {
            return TextUtils.equals(expectedText, cursor.getString(cursor.getColumnIndex(columnName)));
        }
    };
}