我开发了一个Android应用并使用了会议室数据库。 U首次安装该应用程序时,该应用程序将崩溃,并且例外情况是
Fatal Exception: android.database.sqlite.SQLiteException
index index_LocationHistoryBean_address already exists (code 1): , while compiling: CREATE INDEX `index_LocationHistoryBean_address` ON `LocationHistoryBean` (`address`)
我的dao文件是
@Entity(indices = {@Index("address") , @Index("title")})
public class LocationHistoryBean extends BaseObservable implements Parcelable {
@PrimaryKey(autoGenerate = true)
private int id;
private String address;
private double latitude;
private double longitude;
private Date cacheDate;
private String icon;
private String title;
private boolean inTrafficZone;
private boolean inOddEvenZone;
private String category;
private Boolean isHistory = false;
public LocationHistoryBean() {
}
protected LocationHistoryBean(Parcel in) {
id = in.readInt();
address = in.readString();
latitude = in.readDouble();
longitude = in.readDouble();
icon = in.readString();
title = in.readString();
inTrafficZone = in.readByte() != 0;
inOddEvenZone = in.readByte() != 0;
category = in.readString();
byte tmpIsHistory = in.readByte();
isHistory = tmpIsHistory == 0 ? null : tmpIsHistory == 1;
}
public static final Creator<LocationHistoryBean> CREATOR = new Creator<LocationHistoryBean>() {
@Override
public LocationHistoryBean createFromParcel(Parcel in) {
return new LocationHistoryBean(in);
}
@Override
public LocationHistoryBean[] newArray(int size) {
return new LocationHistoryBean[size];
}
};
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Bindable
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
notifyPropertyChanged(BR.address);
}
@Bindable
public double getLatitude() {
return latitude;
}
public void setLatitude(double latitude) {
this.latitude = latitude;
notifyPropertyChanged(BR.latitude);
}
@Bindable
public double getLongitude() {
return longitude;
}
public void setLongitude(double longitude) {
this.longitude = longitude;
notifyPropertyChanged(BR.longitude);
}
public Date getCacheDate() {
return cacheDate;
}
public void setCacheDate(Date cacheDate) {
this.cacheDate = cacheDate;
}
@Bindable
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
notifyPropertyChanged(BR.icon);
}
@Bindable
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
notifyPropertyChanged(BR.title);
}
@Bindable
public boolean isInTrafficZone() {
return inTrafficZone;
}
public void setInTrafficZone(boolean inTrafficZone) {
this.inTrafficZone = inTrafficZone;
notifyPropertyChanged(BR.inTrafficZone);
}
@Bindable
public boolean isInOddEvenZone() {
return inOddEvenZone;
}
public void setInOddEvenZone(boolean inOddEvenZone) {
this.inOddEvenZone = inOddEvenZone;
notifyPropertyChanged(BR.inOddEvenZone);
}
@Bindable
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
notifyPropertyChanged(BR.category);
}
@Bindable
public Boolean getHistory() {
return isHistory;
}
public void setHistory(Boolean history) {
isHistory = history;
notifyPropertyChanged(BR.history);
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(id);
dest.writeString(address);
dest.writeDouble(latitude);
dest.writeDouble(longitude);
dest.writeString(icon);
dest.writeString(title);
dest.writeByte((byte) (inTrafficZone ? 1 : 0));
dest.writeByte((byte) (inOddEvenZone ? 1 : 0));
dest.writeString(category);
dest.writeByte((byte) (isHistory == null ? 0 : isHistory ? 1 : 2));
}
public LatLng getLocationAsLatlng(){return new LatLng(getLatitude() , getLongitude());}
}