Android 12 Developer Preview is here! Try it out, and give us your feedback!

ColumnInfo

@Target([AnnotationTarget.FIELD, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER]) class ColumnInfo
androidx.room.ColumnInfo

Allows specific customization about the column associated with this field.

For example, you can specify a column name for the field or change the column's type affinity.

Summary

Nested classes

The SQLite column type constants that can be used in typeAffinity()

Constants
static Int

Collation sequence for case-sensitive match.

static Int

Column affinity constant for binary data.

static String

Constant to let Room inherit the field name as the column name.

static Int

Column affinity constant for integers or booleans.

static Int

Collation sequence that uses system's current locale.

static Int

Collation sequence for case-insensitive match.

static Int

Column affinity constant for floats or doubles.

static Int

Collation sequence for case-sensitive match except that trailing space characters are ignored.

static Int

Column affinity constant for strings.

static Int

Undefined type affinity.

static Int

Collation sequence that uses Unicode Collation Algorithm.

static Int

Collation sequence is not specified.

static String

A constant for defaultValue() that makes the column to have no default value.

Public constructors
<init>(name: String, typeAffinity: Int, index: Boolean, collate: Int, defaultValue: String)

Allows specific customization about the column associated with this field.

Properties
Int

The collation sequence for the column, which will be used when constructing the database.

String

The default value for this column.

Boolean

Convenience method to index the field.

String

Name of the column in the database.

Int

The type affinity for the column, which will be used when constructing the database.

Constants

BINARY

static val BINARY: Int

Collation sequence for case-sensitive match.

Value: 2

See Also

BLOB

static val BLOB: Int

Column affinity constant for binary data.

Value: 5

See Also

INHERIT_FIELD_NAME

static val INHERIT_FIELD_NAME: String

Constant to let Room inherit the field name as the column name. If used, Room will use the field name as the column name.

Value: "[field-name]"

INTEGER

static val INTEGER: Int

Column affinity constant for integers or booleans.

Value: 3

See Also

LOCALIZED

@RequiresApi(21) static val LOCALIZED: Int

Collation sequence that uses system's current locale.

Value: 5

See Also

NOCASE

static val NOCASE: Int

Collation sequence for case-insensitive match.

Value: 3

See Also

REAL

static val REAL: Int

Column affinity constant for floats or doubles.

Value: 4

See Also

RTRIM

static val RTRIM: Int

Collation sequence for case-sensitive match except that trailing space characters are ignored.

Value: 4

See Also

TEXT

static val TEXT: Int

Column affinity constant for strings.

Value: 2

See Also

UNDEFINED

static val UNDEFINED: Int

Undefined type affinity. Will be resolved based on the type.

Value: 1

See Also

UNICODE

@RequiresApi(21) static val UNICODE: Int

Collation sequence that uses Unicode Collation Algorithm.

Value: 6

See Also

UNSPECIFIED

static val UNSPECIFIED: Int

Collation sequence is not specified. The match will behave like BINARY.

Value: 1

See Also

VALUE_UNSPECIFIED

static val VALUE_UNSPECIFIED: String

A constant for defaultValue() that makes the column to have no default value.

Value: "[value-unspecified]"

Public constructors