I was referring Index specific columns of Room Database.
Below is some example code is written here https://developer.android.com/training/data-storage/room/defining-data#column-indexing
Example Code-1:
@Entity(indices = {@Index("name"),
@Index(value = {"last_name", "address"})})
public class User {
@PrimaryKey
public int id;
public String firstName;
public String address;
@ColumnInfo(name = "last_name")
public String lastName;
@Ignore
Bitmap picture;
}
Example Code-2:
@Entity(indices = {@Index(value = {"first_name", "last_name"},
unique = true)})
public class User {
@PrimaryKey
public int id;
@ColumnInfo(name = "first_name")
public String firstName;
@ColumnInfo(name = "last_name")
public String lastName;
@Ignore
Bitmap picture;
}
This is described in room documentation by android, I have used indices for the uniqueness of column but what does above code means can anyone explain it?
Q1: What is the use of indices and @Index?
Q2: What is the difference between @Index("name")
and @Index(value = {"last_name", "address"})
?