SugarORM: SugarRecord.count returns 4, but SugarRecord.listAll returns an empty list

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); // returns 4 (eg) List<Syllable> syllables = SugarRecord.listAll(Syllable.class); // returns empty list } 
0
source share
1 answer

OK, I just lacked an empty constructor in the model> _> The problem is that it was not printed as an error with an error in the error style in the Android studio, so I just skipped this: D

+1
source

All Articles