Room database exception in first time app install
up vote
0
down vote
favorite
I developed an Android app and using room database.
When U install the app for the first time, the app crashes, and the exception is
Fatal Exception: android.database.sqlite.SQLiteException
index index_LocationHistoryBean_address already exists (code 1): , while compiling: CREATE INDEX `index_LocationHistoryBean_address` ON `LocationHistoryBean` (`address`)
My dao file is
@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());}
}
java android android-room
add a comment |
up vote
0
down vote
favorite
I developed an Android app and using room database.
When U install the app for the first time, the app crashes, and the exception is
Fatal Exception: android.database.sqlite.SQLiteException
index index_LocationHistoryBean_address already exists (code 1): , while compiling: CREATE INDEX `index_LocationHistoryBean_address` ON `LocationHistoryBean` (`address`)
My dao file is
@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());}
}
java android android-room
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I developed an Android app and using room database.
When U install the app for the first time, the app crashes, and the exception is
Fatal Exception: android.database.sqlite.SQLiteException
index index_LocationHistoryBean_address already exists (code 1): , while compiling: CREATE INDEX `index_LocationHistoryBean_address` ON `LocationHistoryBean` (`address`)
My dao file is
@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());}
}
java android android-room
I developed an Android app and using room database.
When U install the app for the first time, the app crashes, and the exception is
Fatal Exception: android.database.sqlite.SQLiteException
index index_LocationHistoryBean_address already exists (code 1): , while compiling: CREATE INDEX `index_LocationHistoryBean_address` ON `LocationHistoryBean` (`address`)
My dao file is
@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());}
}
java android android-room
java android android-room
edited Nov 11 at 12:23
Zoe
10.6k73575
10.6k73575
asked Nov 11 at 12:22
Alireza Khosroabadi
11
11
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248714%2froom-database-exception-in-first-time-app-install%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown