Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace list? #106

Open
LimitTech opened this issue Apr 13, 2016 · 2 comments
Open

Replace list? #106

LimitTech opened this issue Apr 13, 2016 · 2 comments

Comments

@LimitTech
Copy link

Hello!

I'm using this function in order to replace items from an API REST:

private <T extends Rush> void saveList(List<T> models) {
    for (T model : models) {
        ((Model) model).registerWithId(); // RushCore.getInstance().registerObjectWithId(this, getId()) and getId is public String getId() { return String.valueOf(id); }
    }
    RushCore.getInstance().saveOnlyWithoutConflict(models);
}

And I'm getting android.database.sqlite.SQLiteConstraintException: column rush_id is not unique (code 19) when the app is opened again.

Any ideas?

@ghost
Copy link

ghost commented Apr 15, 2016

Hi,

You can't override the getId function.

Once you have called "registerObjectWithId" getId on the base class will return the value you just registered.

I'd try removing the getId function from you class and just changing the register method to this

RushCore.getInstance().registerObjectWithId(this, String.valueOf(id));

Let me know if this works.

Cheers

@LimitTech
Copy link
Author

I think it's working! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant