Example usage for android.provider BaseColumns _COUNT

List of usage examples for android.provider BaseColumns _COUNT

Introduction

In this page you can find the example usage for android.provider BaseColumns _COUNT.

Prototype

String _COUNT

To view the source code for android.provider BaseColumns _COUNT.

Click Source Link

Document

The count of rows in a directory.

Usage

From source file:io.requery.android.database.sqlite.SQLiteQueryBuilder.java

private String[] computeProjection(String[] projectionIn) {
    if (projectionIn != null && projectionIn.length > 0) {
        if (mProjectionMap != null) {
            String[] projection = new String[projectionIn.length];
            int length = projectionIn.length;

            for (int i = 0; i < length; i++) {
                String userColumn = projectionIn[i];
                String column = mProjectionMap.get(userColumn);

                if (column != null) {
                    projection[i] = column;
                    continue;
                }/*from  ww w  .  j av  a  2  s  .c o  m*/

                if (!mStrict && (userColumn.contains(" AS ") || userColumn.contains(" as "))) {
                    /* A column alias already exist */
                    projection[i] = userColumn;
                    continue;
                }

                throw new IllegalArgumentException("Invalid column " + projectionIn[i]);
            }
            return projection;
        } else {
            return projectionIn;
        }
    } else if (mProjectionMap != null) {
        // Return all columns in projection map.
        Set<Entry<String, String>> entrySet = mProjectionMap.entrySet();
        String[] projection = new String[entrySet.size()];
        Iterator<Entry<String, String>> entryIter = entrySet.iterator();
        int i = 0;

        while (entryIter.hasNext()) {
            Entry<String, String> entry = entryIter.next();

            // Don't include the _count column when people ask for no projection.
            if (entry.getKey().equals(BaseColumns._COUNT)) {
                continue;
            }
            projection[i++] = entry.getValue();
        }
        return projection;
    }
    return null;
}