ColumnInfo
public
abstract
@interface
ColumnInfo
implements
Annotation
| 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 | |
|---|---|
@interface |
ColumnInfo.Collate
|
@interface |
ColumnInfo.SQLiteTypeAffinity
The SQLite column type constants that can be used in |
Constants | |
|---|---|
int |
BINARY
Collation sequence for case-sensitive match. |
int |
BLOB
Column affinity constant for binary data. |
String |
INHERIT_FIELD_NAME
Constant to let Room inherit the field name as the column name. |
int |
INTEGER
Column affinity constant for integers or booleans. |
int |
LOCALIZED
Collation sequence that uses system's current locale. |
int |
NOCASE
Collation sequence for case-insensitive match. |
int |
REAL
Column affinity constant for floats or doubles. |
int |
RTRIM
Collation sequence for case-sensitive match except that trailing space characters are ignored. |
int |
TEXT
Column affinity constant for strings. |
int |
UNDEFINED
Undefined type affinity. |
int |
UNICODE
Collation sequence that uses Unicode Collation Algorithm. |
int |
UNSPECIFIED
Collation sequence is not specified. |
Public methods | |
|---|---|
int
|
collate()
The collation sequence for the column, which will be used when constructing the database. |
boolean
|
index()
Convenience method to index the field. |
String
|
name()
Name of the column in the database. |
int
|
typeAffinity()
The type affinity for the column, which will be used when constructing the database. |
Inherited methods | |
|---|---|
Constants
BINARY
public static final int BINARY
Collation sequence for case-sensitive match.
See also:
Constant Value: 2 (0x00000002)
BLOB
public static final int BLOB
Column affinity constant for binary data.
See also:
Constant Value: 5 (0x00000005)
INHERIT_FIELD_NAME
public static final String INHERIT_FIELD_NAME
Constant to let Room inherit the field name as the column name. If used, Room will use the field name as the column name.
Constant Value: "[field-name]"
INTEGER
public static final int INTEGER
Column affinity constant for integers or booleans.
See also:
Constant Value: 3 (0x00000003)
LOCALIZED
public static final int LOCALIZED
Collation sequence that uses system's current locale.
See also:
Constant Value: 5 (0x00000005)
NOCASE
public static final int NOCASE
Collation sequence for case-insensitive match.
See also:
Constant Value: 3 (0x00000003)
REAL
public static final int REAL
Column affinity constant for floats or doubles.
See also:
Constant Value: 4 (0x00000004)
RTRIM
public static final int RTRIM
Collation sequence for case-sensitive match except that trailing space characters are ignored.
See also:
Constant Value: 4 (0x00000004)
TEXT
public static final int TEXT
Column affinity constant for strings.
See also:
Constant Value: 2 (0x00000002)
UNDEFINED
public static final int UNDEFINED
Undefined type affinity. Will be resolved based on the type.
See also:
Constant Value: 1 (0x00000001)
UNICODE
public static final int UNICODE
Collation sequence that uses Unicode Collation Algorithm.
See also:
Constant Value: 6 (0x00000006)
UNSPECIFIED
public static final int UNSPECIFIED
Collation sequence is not specified. The match will behave like BINARY.
See also:
Constant Value: 1 (0x00000001)
Public methods
collate
public int collate ()
The collation sequence for the column, which will be used when constructing the database.
The default value is UNSPECIFIED. In that case, Room does not add any
collation sequence to the column, and SQLite treats it like BINARY.
| Returns | |
|---|---|
int |
The collation sequence of the column. This is either UNSPECIFIED,
BINARY, NOCASE, RTRIM, LOCALIZED or UNICODE.
|
index
public boolean index ()
Convenience method to index the field.
If you would like to create a composite index instead, see: Index.
| Returns | |
|---|---|
boolean |
True if this field should be indexed, false otherwise. Defaults to false. |
name
public String name ()
Name of the column in the database. Defaults to the field name if not set.
| Returns | |
|---|---|
String |
Name of the column in the database. |
typeAffinity
public int typeAffinity ()
The type affinity for the column, which will be used when constructing the database.
If it is not specified, the value defaults to UNDEFINED and Room resolves it based
on the field's type and available TypeConverters.
See SQLite types documentation for details.
| Returns | |
|---|---|
int |
The type affinity of the column. This is either UNDEFINED, TEXT,
INTEGER, REAL, or BLOB.
|
Annotations
Classes
Enums
Exceptions
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.