I use the @Table annotation for my model and call SugarRecord.save in DialogFragment.setPositiveButton.onClick
In the ListView Snippet, I wanted to load all the entries via SugarRecord.listAll , but it returns an empty list, although SugarRecord.count returns the correct score.
My code
Syllable.java
@Table @ToString @Getter public class Syllable { private Long id; @Unique String characters; @Setter boolean active = true; public Syllable(String characters) { this.characters = characters; } }
DialogFragment.setPositiveButton
.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { SugarRecord.save(new Syllable(charactersET.getText().toString())); syllableDialogListener.onSyllableSave(); } })
Fragment.onSyllableSave
private void updateSyllables() { long count = SugarRecord.count(Syllable.class);
source share