Skip to content

Instantly share code, notes, and snippets.

@LeeReindeer
Created August 19, 2017 02:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LeeReindeer/35c4e563c01b0393a232812c960e335d to your computer and use it in GitHub Desktop.
Save LeeReindeer/35c4e563c01b0393a232812c960e335d to your computer and use it in GitHub Desktop.
public int nextID() {
try {
Number number = realm.where(object).max("id");
if (number != null) {
return number.intValue() + 1;
} else {
return 0;
}
} catch (ArrayIndexOutOfBoundsException e) {
return 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment