K
K
kirvel2020-07-30 14:21:45
Java
kirvel, 2020-07-30 14:21:45

How to update an object in Realm using its old value?

I am using Realm as a database in my project.

I have the following class which is inherited from RealmObject:

public class Note extends RealmObject {

private String day,hour, minute;
@RealmField(name = "id")
private int id;

public int getId() {
    return id;
}

public void setId(int id) {
    this.id = id;
}

public Note() {
}
public Note(String day, String hour, String minute) {
    this.day = day;
    this.hour = hour;
    this.minute = minute;
}

public String getDay() {
    return day;
}

void setDay(String day) {
    this.day = day;
}

public String getHour() {
    return hour;
}

void setHour(String hour) {
    this.hour = hour;
}

public String getMinute() {
    return minute;
}

void setMinute(String minute) {
    this.minute = minute;
}
}


I want to make it so that when an object is deleted from the database, the 'id' field of all other objects decreases by 1.

How can I implement this?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question