room/runtime/src/main/java/androidx/room/util/TableInfo.java
@Nullable
    private static Set<Index> readIndices(SupportSQLiteDatabase database, String tableName) {
        Cursor cursor = database.query("PRAGMA index_list(`" + tableName + "`)");
        try {
            final int nameColumnIndex = cursor.getColumnIndex("name");
            final int originColumnIndex = cursor.getColumnIndex("origin");
            final int uniqueIndex = cursor.getColumnIndex("unique");
            if (nameColumnIndex == -1 || originColumnIndex == -1 || uniqueIndex == -1) {
                // we cannot read them so better not validate any index.
                return null;
            }
            HashSet<Index> indices = new HashSet<>();
            while (cursor.moveToNext()) {
                String origin = cursor.getString(originColumnIndex);
                if (!"c".equals(origin)) {
                    // Ignore auto-created indices
                    continue;
                }
                String name = cursor.getString(nameColumnIndex);
                boolean unique = cursor.getInt(uniqueIndex) == 1;
                Index index = readIndex(database, name, unique);
                if (index == null) {
                    // we cannot read it properly so better not read it
                    return null;
                }
                indices.add(index);
            }
            return indices;
        } finally {
            cursor.close();
        }
    }
/**
     * @return null if we cannot read the indices due to older sqlite implementations.
     */
@return null if we cannot read the indices due to older sqlite implementations.
@return null if we cannot read the indices due to older sqlite implementations .
@Nullable
    private static Set<Index> readIndices(SupportSQLiteDatabase database, String tableName) {
        Cursor cursor = database.query("PRAGMA index_list(`" + tableName + "`)");
        try {
            final int nameColumnIndex = cursor.getColumnIndex("name");
            final int originColumnIndex = cursor.getColumnIndex("origin");
            final int uniqueIndex = cursor.getColumnIndex("unique");
            if (nameColumnIndex == -1 || originColumnIndex == -1 || uniqueIndex == -1) {
                return null;
            }
            HashSet<Index> indices = new HashSet<>();
            while (cursor.moveToNext()) {
                String origin = cursor.getString(originColumnIndex);
                if (!"c".equals(origin)) {
                    continue;
                }
                String name = cursor.getString(nameColumnIndex);
                boolean unique = cursor.getInt(uniqueIndex) == 1;
                Index index = readIndex(database, name, unique);
                if (index == null) {
                    return null;
                }
                indices.add(index);
            }
            return indices;
        } finally {
            cursor.close();
        }
    }
@ Nullable private static Set < Index > readIndices ( SupportSQLiteDatabase database , String tableName ) { Cursor cursor = database . query ( "PRAGMA index_list(`" + tableName + "`)" ) ; try { final int nameColumnIndex = cursor . getColumnIndex ( "name" ) ; final int originColumnIndex = cursor . getColumnIndex ( "origin" ) ; final int uniqueIndex = cursor . getColumnIndex ( "unique" ) ; if ( nameColumnIndex == - 1 || originColumnIndex == - 1 || uniqueIndex == - 1 ) { return null ; } HashSet < Index > indices = new HashSet < > ( ) ; while ( cursor . moveToNext ( ) ) { String origin = cursor . getString ( originColumnIndex ) ; if ( ! "c" . equals ( origin ) ) { continue ; } String name = cursor . getString ( nameColumnIndex ) ; boolean unique = cursor . getInt ( uniqueIndex ) == 1 ; Index index = readIndex ( database , name , unique ) ; if ( index == null ) { return null ; } indices . add ( index ) ; } return indices ; } finally { cursor . close ( ) ; } }
@return null if we cannot read the indices due to older sqlite implementations.
@return null if we cannot read the indices due to older sqlite implementations .
// we cannot read them so better not validate any index. // Ignore auto-created indices // we cannot read it properly so better not read it